Monte Carlo State-Value Prediction
The Gradient Monte Carlo Algorithm evaluates a policy by adjusting the weights of a differentiable value-function approximation.
From Episode to Prediction
The Gradient Monte Carlo Algorithm evaluates a policy by adjusting the weights of a differentiable approximation to the value function. Rather than requiring the exact value of a state before learning, it generates a complete episode using policy π, observes the return from each visited state, and uses those returns to correct the approximation.
Tracing One Episode
Suppose an episode visits states at times 0 through T − 1 before reaching its terminal point. For every nonterminal time step t, the algorithm takes the state S_t and the return G_t obtained from the rest of that completed episode. It then compares that return with the current approximate value v̂(S_t, θ). The same process is carried out for every visited nonterminal state in the episode.
The return G_t is not the exact value of S_t in a particular episode. It is one sampled return after that state. The true state value vπ(S_t) is the expected return after S_t under policy π. Therefore, G_t is an unbiased estimate of vπ(S_t): across the relevant sampling process, its expected value equals the true state value. This makes the return suitable as a target for correcting the approximate value.
Updating the Approximation
For a visited state S_t, the Gradient Monte Carlo update compares the sampled return G_t with the current approximation v̂(S_t, θ). The difference G_t − v̂(S_t, θ) is the prediction error. The algorithm multiplies this error by the gradient of the approximation with respect to the weights, scales the result by the step size α, and adds it to θ.
θ ← θ + α [G_t − v̂(S_t, θ)] ∇v̂(S_t, θ)
Calculating one parameter update
Consider one visited state with current approximate value 4, return G_t equal to 10, step size α equal to 0.1, gradient [1, −2], and current weight vector [2, 3].
Find the prediction error: The prediction error is 10 − 4 = 6.
Scale the gradient: Multiply the error by the step size and gradient: 0.1 × 6 × [1, −2] = [0.6, −1.2].
Add the adjustment: Add the adjustment to the current weights: [2, 3] + [0.6, −1.2].
The updated weight vector is [2.6, 1.8].
The example shows why the update changes weights rather than directly replacing a table entry. The approximation is represented by v̂(S_t, θ), so learning acts on θ. The gradient determines the direction in weight space, while the prediction error determines whether and how strongly the weights should be adjusted.
Convergence Conditions
The convergence guarantee depends on the target being unbiased. More generally, if a target U_t satisfies E[U_t] = vπ(S_t) for every t, and the step size α decreases according to the usual stochastic approximation conditions, then the parameter sequence θ_t is guaranteed to converge to a local optimum.
Common Reasoning Errors
Treating one return as the exact value of the state.
G_t is one sampled return. It is an unbiased estimate because its expected value is vπ(S_t), not because every sample is identical to the expectation.
Fix:
Use the return as a target for an update while remembering that individual returns can differ from the true state value.Updating only the state value instead of the approximation weights.
The Gradient Monte Carlo Algorithm represents the value approximation as v̂(S_t, θ), so the update changes the parameter vector θ.
Fix:
Apply the prediction error, gradient, and step size to the weight vector.Using a return before the episode is complete.
The algorithm uses complete episodes generated by policy π and obtains each return from that completed episode.
Fix:
Generate the complete episode, obtain the return for each visited nonterminal state, and then perform the updates.Stating convergence without its assumptions.
The convergence statement requires an unbiased target and a decreasing step size satisfying the usual stochastic approximation conditions.
Fix:
State both the target condition and the step-size condition, and describe the destination as a local optimum.
Check Your Understanding
A visited state has current approximate value 7 and sampled return 3. The step size is α, and the gradient is g. Describe the update direction before substituting any numerical value for α or g.
Hints
- Start with the prediction error G_t − v̂(S_t, θ).
- Determine whether the error is positive or negative.
- Multiply that error by the gradient and step size.
Explain why averaging sampled returns from a state can estimate its true value under policy π, even though an individual return may not equal that value.
Hints
- Recall the definition of the true state value as an expected return.
- Use the fact that G_t is an unbiased estimate of vπ(S_t).
What do you think happens?
If the sampled return is smaller than the current approximate value, what sign does the prediction error have?
Reveal answer
Answer: Negative
The prediction error is G_t − v̂(S_t, θ). When G_t is smaller than the current approximation, the difference is negative. The resulting weight adjustment is determined by that negative error together with the gradient and step size.
Key Takeaways
- The Gradient Monte Carlo Algorithm evaluates policy π using complete episodes and a differentiable value-function approximation.
- Each return G_t is a sampled target for its corresponding visited state and is an unbiased estimate of vπ(S_t).
- The update changes θ using the prediction error, the approximation gradient, and the step size α.
- The update is applied for every nonterminal time step in the generated episode.
- With an unbiased target and a suitable decreasing step-size schedule, the parameter sequence converges to a local optimum.
Key Takeaways
- A complete episode supplies a return for each visited nonterminal state.
- The return G_t estimates the true state value because the true value is the expected return after the state.
- The parameter update moves the differentiable approximation using the prediction error, its gradient, and the step size.
- The convergence guarantee requires unbiased targets and a decreasing step size satisfying the usual stochastic approximation conditions.
- Under those conditions, the parameter sequence converges to a local optimum.