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 x1,x2,…,xmx_1, x_2, \ldots, x_m and eventually learn the outcome zz. The goal is to produce a prediction PtP_t at each step that estimates zz as accurately as possible.

The conventional supervised-learning approach treats each step as an independent observation-outcome pair (xt,z)(x_t, z) and updates using the Widrow-Hoff (delta) rule:

Δwt=α(z−Pt)∇wPt\Delta w_t = \alpha (z - P_t) \nabla_w P_t
Widrow-Hoff (supervised) update rule — Wait until the outcome z is known, compute the error z − Pₜ for every step, then update all weights at once. This requires storing all observations and cannot run incrementally.

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.

Open in Lab
Compare when supervised learning vs TD learning can update weights. Toggle the method to see how TD learns incrementally while supervised learning must wait.
The demo wakes as you arrive…

The key insight: learn from the difference between successive predictions

Sutton's breakthrough is to notice that the total error z−Ptz - P_t can be decomposed into a telescoping sum of successive prediction differences:

z−Pt=∑k=tm(Pk+1−Pk)z - P_t = \sum_{k=t}^{m} (P_{k+1} - P_k)

where Pm+1=defzP_{m+1} \stackrel{\text{def}}{=} z. Instead of waiting for zz, the learner can update after each step using only the change from PtP_t to Pt+1P_{t+1}. This is the essence of temporal-difference learning.

Open in Lab
Step through a weather prediction sequence. Watch how TD updates predictions day-by-day while supervised learning waits until Saturday.
The demo wakes as you arrive…

The TD(λ) family: from full hindsight to pure bootstrapping

Sutton defines a spectrum of TD methods parameterized by λ∈[0,1]\lambda \in [0, 1]. The update rule is:

Δwt=α(Pt+1−Pt)∑k=1tλt−k∇wPk\Delta w_t = \alpha (P_{t+1} - P_t) \sum_{k=1}^{t} \lambda^{t-k} \nabla_w P_k
The TD(λ) update rule — λ controls the credit assignment horizon. λ = 1 recovers the Widrow-Hoff supervised rule. λ = 0 uses only the most recent observation to assign credit. Values in between blend the two extremes exponentially.

Think of λ\lambda as a memory dial. Turn it all the way up (λ=1\lambda = 1) and the learner gives equal credit to all past observations — exactly like . Turn it all the way down (λ=0\lambda = 0) 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 λt−k\lambda^{t-k} has a beautifully incremental form. Define the ete_t:

et=∇wPt+λ et−1e_t = \nabla_w P_t + \lambda \, e_{t-1}

This trace is a running sum that decays old gradients by λ\lambda at each step. It allows TD(λ\lambda) to be computed with constant memory per step — no need to store the entire history.

Open in Lab
Drag the λ slider and watch how credit spreads across past states. At λ=0 only the immediate predecessor gets credit; at λ=1 all states share equally.
The demo wakes as you arrive…

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 z=0z = 0; if it reaches G (right edge) the outcome is z=1z = 1. The task is to predict, for each state, the probability of terminating at G.

The true probabilities are 16,26,36,46,56\frac{1}{6}, \frac{2}{6}, \frac{3}{6}, \frac{4}{6}, \frac{5}{6} for states B through F. This problem is one of the simplest dynamical systems imaginable, yet it cleanly reveals the advantage of TD methods.

Open in Lab
Run random walks and compare TD(0) vs Widrow-Hoff learning. Watch how TD(0) converges to the true values faster with less error.
The demo wakes as you arrive…

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 λ<1\lambda < 1. Under single presentation (one pass through the data), TD methods with λ≈0.3\lambda \approx 0.3 performed best, but all λ<1\lambda < 1 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 λ=0\lambda = 0, the update rule reaches its simplest and most distinctive form:

Δwt=α(Pt+1−Pt)∇wPt\Delta w_t = \alpha (P_{t+1} - P_t) \nabla_w P_t
TD(0) update — the foundation of modern RL — Identical to the supervised rule except z is replaced by Pₜ₊₁. The learner uses its own next prediction as the target — this is bootstrapping. No history storage needed.

The term (Pt+1−Pt)(P_{t+1} - P_t) is now called the and is universally denoted δt\delta_t 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 Pt+1P_{t+1} incorporates one more step of real-world information than PtP_t: it has seen the actual next state. This extra observation makes Pt+1P_{t+1} a better performance standard than the distant and noisy final outcome zz.

Open in Lab
See how bootstrapping propagates information backward through a chain of states. Click each state to see its TD error and weight update.
The demo wakes as you arrive…

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 α\alpha, 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

Linear TD(0) and TD(λ) on an absorbing Markov chainpython

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 ct+1c_{t+1} is the cost incurred between steps tt and t+1t+1, the prediction target becomes:

zt=∑k=tmck+1z_t = \sum_{k=t}^{m} c_{k+1}

The TD error generalizes to (ct+1+Pt+1−Pt)(c_{t+1} + P_{t+1} - P_t), which is exactly the form used in modern reinforcement learning. With a γ\gamma, this becomes the discounted TD error:

δt=ct+1+γPt+1−Pt\delta_t = c_{t+1} + \gamma P_{t+1} - P_t

This is the update signal of Sutton's own (1984), and it is precisely the signal used by every modern value-based RL algorithm.

δt=rt+1+γV(st+1)−V(st)\delta_t = r_{t+1} + \gamma V(s_{t+1}) - V(s_t)
Modern TD error (the heartbeat of RL) — rₜ₊₁ = reward at next step · γ = discount factor · V(s) = value estimate for state s · This single equation drives Q-learning, SARSA, actor-critic, and all their descendants.

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: V(s)=∑aπ(a∣s)∑s′p(s′∣s,a)[r+γV(s′)]V(s) = \sum_a \pi(a|s) \sum_{s'} p(s'|s,a) [r + \gamma V(s')]. It is exact but requires a complete model — transition probabilities and rewards for every state-action pair.

methods estimate values by averaging complete returns: V(s)≈average of GtV(s) \approx \text{average of } G_t 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.

Open in Lab
The three pillars of value estimation. Click each method to see its update rule, requirements, and trade-offs.
The demo wakes as you arrive…

The legacy that built modern RL

  1. 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.

  2. 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.

  3. 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.

  4. 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.

  5. 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.

  6. 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.

  7. 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