A tabular value function is V=0 for states A, B, C. One episode goes A → B → C → end with rewards 0,0,1. Use TD(λ) with accumulating traces, γ=0.9, λ=0.8 and α=0.1, and update every state at every step. What is V after the episode? How does this differ from TD(0)?

Reinforcement learning, Eligibility traces
Level L3 Intermediate. Length Medium. Nature Mat Mathematical.

What's being asked

Whether you can run the backward view of TD(λ): update every state in proportion to its eligibility trace.

Key idea

At each step compute the TD error δt=rt+1+γV(St+1)−V(St). Decay all traces by γλ, add 1 to the trace of the current state, and update every state by V(s)←V(s)+α δt e(s).

Steps

  1. Step 1 (at A): δ=0+0.9×0−0=0. Trace e(A)=1. No value changes because δ=0.
  2. Step 2 (at B): decay by γλ=0.72, so e(A)=0.72, then e(B)=1. δ=0 again, so V is unchanged.
  3. Step 3 (at C): decay, so e(A)=0.722=0.5184 and e(B)=0.72, then e(C)=1. The reward arrives: δ=1+0.9×0−0=1 (the end state has value 0).
  4. Update every state: V(A)=0.1×1×0.5184=0.05184, V(B)=0.1×0.72=0.072, V(C)=0.1×1=0.1.
  5. Compare with TD(0). TD(0) would update only C, giving V(C)=0.1 and leaving V(A)=V(B)=0. The trace passes credit back to earlier states in one episode, with weights (γλ)k for a state k steps back.
  6. State the limits: λ=0 is TD(0) and λ=1 behaves like Monte Carlo, with trace weights γk.

Common mistakes

How long your answer should be

Half a page; 5 minutes.

Last checked on 4 December 2026.

Read this

Previous in Reinforcement learning: Four episodes are generated by a behaviour policy b. For a target policy π, the importance ratios ρ=∏tπ(at∣st)/b(at∣st) and the returns G are (ρ,G)=(4,8), (0,5), (2,3) and (4,2). Compute the ordinary and weighted importance-sampling estimates of Vπ at the start state. Which is biased, and which has higher variance?
Next 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?