Temporal-Difference Learning: Update a Value from One Transition
Published:
Learn from a step before knowing the whole outcome
Intuition first. You predicted that a route would yield return 4. After one step, you receive reward 1 and arrive somewhere currently valued at 5. With discount 0.9, that experience suggests a target of 5.5 for the earlier state.
For transitions collected under a fixed policy, tabular TD(0) uses
The TD error \(\delta_t\) measures disagreement between the current estimate and a one-step target. The learning rate \(\alpha\) controls how far to move towards that target. Model-free prediction lecture.
Worked example: target, error, update
Take \(V(S_t)=4\), \(R_{t+1}=1\), \(V(S_{t+1})=5\), \(\gamma=0.9\), and \(\alpha=0.2\):
The update does not set the estimate equal to the target because \(\alpha<1\). Nor does a positive TD error prove that the action was objectively good: an inaccurate next-state estimate can make the target overoptimistic.
Compare three kinds of backup
| Method | Information used for the target | Main distinction |
|---|---|---|
| Dynamic programming | Expected outcomes from a model | Sums over possible transitions |
| Monte Carlo prediction | Observed return to episode end | Waits for the sampled outcome |
| TD(0) | One reward plus next-state estimate | Bootstraps immediately |
Monte Carlo targets can vary substantially across episodes. TD uses an imperfect continuation estimate and can propagate its errors. Neither method is universally more accurate for a fixed amount of data.
A terminal transition has no continuation
If the transition ends the task, its target is just the received reward. In the same example, a terminal reward of 1 gives \(\delta=1-4=-3\) and updated value \(4+0.2(-3)=3.4\).
An external collection cutoff is different. If the underlying task would continue, its continuation value remains relevant. Use the final observation before reset for that estimate. A reset observation belongs to a different episode. Gymnasium’s termination and truncation guide explains this distinction.
A time limit that is part of the task definition is a genuine finite-horizon boundary; the state should then account for remaining time. The word “timeout” alone does not determine the correct target.
From one step to several
An \(n\)-step target combines several observed rewards before bootstrapping:
If the task terminates earlier, stop at that boundary and omit the continuation. This connects one-step updates to longer returns and prepares the idea behind generalised advantage estimation.
Next, actor–critic basics explains how value estimates help update the action policy.
References
- Silver, D. Reinforcement Learning course: Model-Free Prediction.
- Farama Foundation. Handling Time Limits.
