Computing the value functions given a policy
This section derives a recursion for the value functions, like the one for the return, and then replaces the expectations with sums over actions and next states. Start with the state-value function: The expectations are over the trajectories that the policy and the transition model generate together. Only the last step needs an argument: it replaces by . The step uses the Markov property of both the environment and the policy. The next state and reward depend only on the current state and action, and the policy chooses each action from the current state alone. So, given , the rewards after do not depend on the earlier states, actions and rewards. Fix one transition from : action , reward and next state . Conditioning the remaining return on this transition gives the same expectation as conditioning on the next state alone, and because the policy is stationary, that expectation is the value of : Averaging over the transitions that can follow , each with probability , gives This recursion is the Bellman expectation equation:Code
Code
Bellman State-Action Value Expectation EquationIn vector form, stacks the values of all state-action pairs and the expected rewards , both with entries:The two matrices split one step into the environment’s part and the policy’s part: moves from a state-action pair to the next states, and averages the action values of a state over the policy, so . The state-value form below follows from the same two matrices: and .
Bellman State Value Expectation EquationIn the vector form on the second line, stacks the values of all states, and and the transition matrix average the rewards and transitions over the policy:
References
- Sutton, R., Barto, A. (2018). Reinforcement Learning: An Introduction. Link
Found an error on this page? Report an issue.

