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

MethodTargetNeeds a model?Waits for episode end?VarianceBias from bootstrapping
Dynamic prog.YesNoNoneNone
Monte CarloFull return NoYesHighNone
Temporal diff.NoNoLowerYes

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.

AspectSARSA (on-policy)Q-learning (off-policy)
Next-action valueaction the policy tookgreedy
Learns value ofthe behavior policy itselfthe greedy policy
Behavior near riskmore conservativemore 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

References