A trajectory of three steps has rewards (1,0,2) and critic values V(s0),V(s1),V(s2)=(3,2,1). The episode ends after step 3, so the next value is 0. With γ=0.9 and λ=0.5, what are the TD errors and the generalised advantage estimates A^0,A^1,A^2?

Reinforcement learning, Actor–critic
Level L3 Intermediate. Length Medium. Nature Mat Mathematical.

What's being asked

Whether you can compute TD errors and combine them backwards with the GAE recursion A^t=δt+γλA^t+1.

Key idea

GAE defines A^t=∑l≥0(γλ)l δt+l, with TD error δt=rt+γV(st+1)−V(st). It is computed backwards with A^t=δt+γλA^t+1.

Steps

  1. TD errors: δ0=1+0.9×2−3=−0.2.
  2. δ1=0+0.9×1−2=−1.1.
  3. δ2=2+0.9×0−1=1, using value 0 after the end.
  4. Here γλ=0.45. Start at the end: A^2=δ2=1.
  5. A^1=δ1+0.45 A^2=−1.1+0.45=−0.65.
  6. A^0=δ0+0.45 A^1=−0.2−0.2925=−0.4925.
  7. Use A^t as the advantage weighting in the policy gradient. For step 2 the action beat the critic's expectation (A^>0), so it is made more likely. For steps 0 and 1 the critic was too optimistic, and those actions are made less likely.

Common mistakes

How long your answer should be

6 lines of arithmetic.

Last checked on 4 December 2026.

Read this

Previous in Reinforcement learning: A two-armed bandit policy is π(a)=softmax(θ)a with θ=(0,0). The agent samples arm 1 and receives reward R=4. Using the REINFORCE update θ←θ+α(R−b)∇θlog⁡π(a) with α=0.1, what is the update (a) with baseline b=0 and (b) with b=2? What is the gradient of log⁡π, and how do you show that the score function has zero mean?
Next in Reinforcement learning: Two Bernoulli arms start with uniform Beta(1,1) priors. Arm A has been pulled 4 times with 3 successes and 1 failure. Arm B has been pulled once with 1 success. Give each arm's posterior, mean and variance. What is the probability that Thompson sampling picks B next? Why is this different from a greedy choice?