Temporal-Difference Learning
Temporal-difference (TD) learning estimates value functions by updating a prediction toward a later, better-informed prediction. It sits between Monte Carlo methods, which wait for a full episode return, and dynamic programming, which needs a known model. TD learns online from raw experience and bootstraps: it updates one estimate using another estimate.
TD Prediction
For a transition under a fixed policy, TD(0) updates the state value:
The bracketed quantity is the TD error:
It measures how much the one-step target disagrees with the current estimate . A positive error means the transition was better than expected, so the estimate moves up.
Three Ways to Estimate a Value
| Method | Target | Needs a model? | Waits for episode end? | Variance | Bias from bootstrapping |
|---|---|---|---|---|---|
| Dynamic prog. | Yes | No | None | None | |
| Monte Carlo | Full return | No | Yes | High | None |
| Temporal diff. | No | No | Lower | Yes |
TD trades a little bias for lower variance and the ability to learn from incomplete, ongoing episodes. This is why it underlies most practical value-based control.
On-Policy Control: SARSA
SARSA learns action values while following the same policy it improves. For a transition where is the action actually taken next:
Because the target uses the next action the current policy chose, SARSA evaluates the policy it is actually running, including its exploration. It tends to learn safer paths when exploration is risky.
Off-Policy Control: Q-Learning
Q-learning replaces with , so it learns the value of the greedy policy regardless of the exploratory actions actually taken. This off-policy target is the main practical difference from SARSA.
| Aspect | SARSA (on-policy) | Q-learning (off-policy) |
|---|---|---|
| Next-action value | action the policy took | greedy |
| Learns value of | the behavior policy itself | the greedy policy |
| Behavior near risk | more conservative | more optimistic |
Worked TD(0) Update
Let , reward , discount , next value , and step size . The target is , so and
n-Step Returns and Eligibility Traces
TD(0) uses a one-step target; Monte Carlo uses the full return. n-step TD interpolates by bootstrapping after rewards:
TD() averages all n-step returns with geometrically decaying weights , and eligibility traces implement this efficiently by assigning credit to recently visited states. Small behaves like TD(0); approaches Monte Carlo.
Caveats
Bootstrapping introduces bias and can diverge when combined with function approximation and off-policy targets, the so-called deadly triad. Step sizes, target networks, and on-policy sampling all mitigate this in practice.
Connections
- Value Functions and Bellman Equations define the fixed point TD updates move toward.
- Q-Learning and DQN is the off-policy TD control method scaled to neural networks.
- Policy Gradients and Actor-Critic Methods use a TD-learned critic to reduce gradient variance.
References
- Sutton and Barto, 2018, Reinforcement Learning: An Introduction (Chapters 6–7, 12)
- Sutton, 1988, Learning to Predict by the Methods of Temporal Differences
- van Seijen et al., 2016, True Online Temporal-Difference Learning
Nav