Mastering the Bellman Equation
Bellman Equation Derivation
From Total Return to a Recursive Loop
You already know that the goal in reinforcement learning is to maximize the expected total return, , from any given time step . It’s the sum of all future rewards, discounted by a factor at each step.
This formula is correct, but it's not very practical for calculation. To make it useful, we need to rephrase it recursively. Notice that the expression for contains a familiar-looking term. If we factor out from all terms except the first, we get something interesting.
The expression inside the parentheses is just the definition of the total return starting from the next time step, . This means we can rewrite the entire equation in a compact, recursive form.
The Bellman Expectation Equations
With our recursive definition of return, we can now define the value functions. The state-value function, , is the expected return an agent can get starting from state and then following policy . The action-value function, , is the expected return from taking action in state and then following policy .
Let's derive the equation for . We start with its definition and substitute our recursive formula for .
This final line is the Bellman expectation equation for . It expresses the value of a state in terms of the expected values of its successor states. It creates a system of linear equations, one for each state, whose unique solution is the value function . A similar derivation gives us the equation for the action-value function, .
The state-value and action-value functions are tightly linked. The value of a state is the expected value of the actions you can take from that state, weighted by your policy.
Finding the Optimal Path
The expectation equations tell us the value of a given policy, but our goal is to find the best policy, . An optimal policy is one that achieves a value function greater than or equal to all other policies for all states. The corresponding optimal value functions are denoted and .
To find these, we invoke the and introduce a max operator into our equations. The value of a state under an optimal policy must be equal to the expected return for the best action from that state.
This equation is the core of many reinforcement learning algorithms. Unlike the expectation equation, it is non-linear due to the max operator. Solving it requires iterative methods like value iteration or policy iteration, which are foundational to in RL.
Similarly, we can write the optimality equation for the action-value function.
Once we have , determining the optimal policy is straightforward. For any state , the best action is the one that maximizes . There is always at least one such action.
Ready to test your understanding?
What is the recursive formula for the expected total return, , starting from time step ?
The Bellman expectation equation for is a system of linear equations, while the Bellman optimality equation for is non-linear.
These equations provide the theoretical foundation for finding optimal policies in any finite Markov Decision Process, forming the bedrock of modern reinforcement learning.