Reinforcement Learning1988intermediate10 min read
Learning to Predict by the Methods of Temporal Differences
التعلُّم بالتنبؤ عبر أساليب الفارق الزمني
Sutton, R. S. — Machine Learning
The problem
Conventional supervised-learning methods must wait until the final outcome is known before updating predictions. This wastes the intermediate information that accumulates along the way, requires storing all observations until the end, and makes poor use of experience in problems where partial clues arrive at every step.
The contribution
A family of incremental learning procedures — the TD(λ) methods — that update predictions based on the difference between temporally successive predictions rather than waiting for the final outcome. The paper proves and optimality for the linear TD(0) case on absorbing Markov chains, shows empirically that TD methods learn faster than supervised-learning methods, and establishes the theoretical framework that would later underpin all of .
The impact
The theoretical bedrock of modern reinforcement learning. TD methods enabled TD-Gammon (backgammon at world-champion level), , SARSA, architectures, and eventually the RLHF pipeline that aligns large language models like GPT and Claude. Every time an RL agent updates its value function from a single transition, it is using a descendant of Sutton's 1988 framework.
Imagine you're hiking toward a mountain peak hidden behind clouds. A supervised learner waits until reaching the summit to judge whether each fork in the trail was a good choice.
A temporal-difference learner checks the altitude at every rest stop. If the path just climbed 200 meters, it upgrades its opinion of the previous fork — before seeing the peak. Each rest stop's reading becomes a stepping stone for learning, not just the final view from the top.
The prediction problem: why waiting for the end wastes information
Sutton frames the core challenge as a multi-step prediction problem. You observe a sequence of states and eventually learn the outcome . The goal is to produce a prediction at each step that estimates as accurately as possible.
The conventional supervised-learning approach treats each step as an independent observation-outcome pair and updates using the Widrow-Hoff (delta) rule:
Think of this like a university professor who collects all exam booklets and grades them only after the semester ends. Every student's midterm performance — a rich signal about what they know — is ignored until the final grade arrives. TD methods, by contrast, are like giving feedback after every quiz: each intermediate signal sharpens the next prediction.
The key insight: learn from the difference between successive predictions
Sutton's breakthrough is to notice that the total error can be decomposed into a telescoping sum of successive prediction differences:
where . Instead of waiting for , the learner can update after each step using only the change from to . This is the essence of temporal-difference learning.
The TD(λ) family: from full hindsight to pure bootstrapping
Sutton defines a spectrum of TD methods parameterized by . The update rule is:
Think of as a memory dial. Turn it all the way up () and the learner gives equal credit to all past observations — exactly like . Turn it all the way down () and only the most recent step matters. In between, recent steps get exponentially more credit than distant ones, like a spotlight that fades with distance.
The key insight is that the exponential weighting has a beautifully incremental form. Define the :
This trace is a running sum that decays old gradients by at each step. It allows TD() to be computed with constant memory per step — no need to store the entire history.
The random walk experiment: proof by practice
To test TD methods empirically, Sutton designed an elegantly simple experiment: a bounded random walk on 7 states (A through G). Every walk starts at the center state D. At each step the walk moves left or right with equal probability. If it reaches A (left edge) the outcome is ; if it reaches G (right edge) the outcome is . The task is to predict, for each state, the probability of terminating at G.
The true probabilities are for states B through F. This problem is one of the simplest dynamical systems imaginable, yet it cleanly reveals the advantage of TD methods.
Sutton found two striking results. Under repeated presentations (showing the same until convergence), TD(0) achieved lower RMS error than the Widrow-Hoff procedure for every value of . Under single presentation (one pass through the data), TD methods with performed best, but all beat the supervised approach.
Why does Widrow-Hoff — a method proven to minimize training-set error — lose? Because minimizing error on the training set is not the same as minimizing error on future data. TD(0) converges to the maximum-likelihood estimates consistent with the underlying Markov process, which generalize better.
TD(0): the simplest yet most powerful member
At , the update rule reaches its simplest and most distinctive form:
The term is now called the and is universally denoted in reinforcement learning. It is the fundamental learning signal of modern RL: every time Q-learning, SARSA, or an actor-critic updates, it is computing a version of this error.
— using your own estimate to improve your estimate — sounds circular, but Sutton proved it works. The intuition is that incorporates one more step of real-world information than : it has seen the actual next state. This extra observation makes a better performance standard than the distant and noisy final outcome .
Convergence: why bootstrapping does not spiral out of control
The deepest contribution of the paper is proving that linear TD(0) converges. This was remarkable because the method learns from its own predictions, which are initially wrong. Earlier TD methods (Samuel's checkers, Holland's bucket brigade) worked well empirically but had no convergence guarantees.
Sutton proves two theorems for data generated by absorbing Markov chains with linearly independent observation vectors:
Theorem 2 (Convergence): With sufficiently small , linear TD(0) converges in expected value to the ideal predictions — the true expected outcomes for each state.
Theorem 3 (Optimality): Under repeated presentations of a finite training set, linear TD(0) converges to the maximum-likelihood estimates — the predictions that would be ideal if the training data perfectly described the true process. Widrow-Hoff, by contrast, converges to the estimates that minimize training-set error, which are generally suboptimal for future data.
The idea in code
Simplified to show the idea — not the real implementation.
import numpy as np
def td_zero(sequences, n_states, alpha=0.05, n_episodes=100):
"""Linear TD(0) for the bounded random walk."""
V = np.full(n_states, 0.5) # initial predictions
for _ in range(n_episodes):
for seq in sequences:
for t in range(len(seq) - 1):
s = seq[t] # current state index
s_ = seq[t + 1] # next state index
# TD error: next prediction minus current prediction
if s_ == 0 or s_ == n_states - 1: # terminal state
target = 1.0 if s_ == n_states - 1 else 0.0
else:
target = V[s_] # bootstrap from own prediction
delta = target - V[s]
V[s] += alpha * delta # the entire TD(0) update
return V
def td_lambda(sequences, n_states, lam=0.3, alpha=0.05, n_episodes=100):
"""Linear TD(λ) with eligibility traces."""
V = np.full(n_states, 0.5)
for _ in range(n_episodes):
for seq in sequences:
e = np.zeros(n_states) # eligibility trace
for t in range(len(seq) - 1):
s = seq[t]
s_ = seq[t + 1]
if s_ == 0 or s_ == n_states - 1:
target = 1.0 if s_ == n_states - 1 else 0.0
else:
target = V[s_]
delta = target - V[s]
e *= lam # decay old traces
e[s] += 1.0 # mark current state
V += alpha * delta * e # update ALL traced states
return V
# The only difference: TD(0) updates one state per step;
# TD(λ) updates all recently visited states, weighted by λ.Extensions: cumulative outcomes and discounting
Sutton extends TD methods beyond predicting a single final outcome to predicting cumulative costs that accumulate over a sequence. If is the cost incurred between steps and , the prediction target becomes:
The TD error generalizes to , which is exactly the form used in modern reinforcement learning. With a , this becomes the discounted TD error:
This is the update signal of Sutton's own (1984), and it is precisely the signal used by every modern value-based RL algorithm.
TD between two giants: dynamic programming and Monte Carlo
TD learning occupies a unique middle ground between two classical approaches:
(Bellman, 1957) computes values from a known model of the environment: . It is exact but requires a complete model — transition probabilities and rewards for every state-action pair.
methods estimate values by averaging complete returns: across episodes. They need no model but must wait until the end of each episode.
TD combines the best of both: like Monte Carlo, it learns from raw experience without a model. Like dynamic programming, it updates estimates based on other estimates (bootstrapping), allowing learning at every step without waiting for the episode to end.
The legacy that built modern RL
1959
Samuel's Checkers
The first use of a TD-like method. Samuel's checker program updated evaluations based on differences between successive position evaluations — the precursor Sutton formalized.
1988
This Paper — TD(λ) Formalized
Sutton isolates TD methods from the larger systems they were embedded in, proves convergence and optimality for TD(0), and introduces the λ parameter that controls the bootstrapping-sampling trade-off.
1989
Q-Learning
Watkins extends TD to control by learning action-values Q(s, a) off-policy. The TD error becomes the Q-learning update — a direct descendant of this paper.
1992
TD-Gammon
Tesauro applies TD(λ) with a neural network to backgammon, achieving world-champion level play. The first dramatic demonstration that TD + function approximation scales to complex domains.
2000
Sutton & Barto's RL Textbook
Codifies TD methods as the central chapter of reinforcement learning theory. TD(0), SARSA, and Q-learning are presented as a unified family built on this paper's insights.
2015
GAE (Generalized Advantage Estimation)
Schulman et al. use TD(λ) to compute advantages for policy gradient methods. The λ parameter from this paper directly controls the bias-variance trade-off in modern policy optimization.
2017
PPO + TD in RLHF
TD-based value functions become the critic in the actor-critic architecture that powers RLHF — the method used to align GPT, Claude, and other LLMs with human preferences.
CitationSutton, R. S.. Learning to Predict by the Methods of Temporal Differences. Machine Learning 3(1), 1988.
Terms in this paper
- Temporal Differenceالفارق الزمني الحسابي
- Bootstrappingالتمهيد الذاتي
- Eligibility Traceأثر الأهلية
- TD Errorخطأ الفارق الزمني
- Credit Assignmentإسناد الائتمان
- Absorbing Markov Chainسلسلة ماركوف الممتصّة
- Widrow-Hoff Ruleقاعدة Widrow-Hoff