TD(lambda) and Eligibility Traces

Imagine an agent learning to predict how long a commute will take. It updates its estimate after every intersection, rather than waiting until it arrives home. If it only updates using the very next step, learning is stable but slow. Information then propagates backward slowly. If it waits for the full trip, updates are unbiased but noisy. They also cannot happen online. n-Step Bootstrapping Methods showed that any fixed lookahead of nn steps interpolates between these extremes. But choosing a single best nn is awkward. Computing many nn-step returns separately is also wasteful. TD(λ\lambda) resolves this by averaging over all nn-step returns at once. These are weighted geometrically by a parameter λ∈[0,1]\lambda \in [0,1]. This produces a single tunable knob. It spans one-step TD at λ=0\lambda=0 to Monte Carlo at λ=1\lambda=1. The elegance of TD(λ\lambda) is not just conceptual — it is computational. Naively averaging infinitely many nn-step returns would seem to require storing an entire episode. It would also require revisiting that episode later. Eligibility traces solve this problem differently. They introduce a compact, decaying memory trace over states (or features). This lets the same forward-looking average be computed differently. Instead, it uses a backward, fully incremental, per-step update. This backward view is mathematically equivalent to the forward λ\lambda-return under offline updates. It also generalizes cleanly to online learning and function approximation. This machinery matters in real systems for a clear reason. Most practical reinforcement learning cannot wait for episodes to end. It also cannot afford to store full trajectories. This is especially true with continuous or non-episodic tasks. It also applies to streaming sensor data or robotic control at high frequency. TD(λ\lambda) with eligibility traces gives an O(1)O(1)-per-step algorithm. It captures much of the variance reduction of long-horizon returns. At the same time, it retains the low latency of one-step bootstrapping. This article builds the λ\lambda-return precisely. It derives the equivalence between the forward view and the backward view. The forward view looks ahead at compound returns. The backward view uses eligibility traces to propagate credit to the past. It gives working pseudocode for both linear function approximation and tabular prediction. It analyzes complexity and correctness. It also works a full numeric trace so the mechanics are unmistakable. It closes by connecting to the fully general machinery used in Semi-Gradient Methods with Function Approximation.

Key takeaways
  • TD(λ\lambda) generalizes n-Step Bootstrapping Methods by averaging all nn-step returns with geometric weights (1−λ)λn−1(1-\lambda)\lambda^{n-1}.
  • λ=0\lambda = 0 recovers one-step TD; λ=1\lambda = 1 recovers Monte Carlo; intermediate λ\lambda trades bias against variance, per Bootstrapping and the Bias-Variance Tradeoff.
  • The forward view defines the λ\lambda-return GtλG_t^\lambda explicitly using future rewards — conceptually clean but not implementable online.
  • The backward view uses an eligibility trace vector that decays by γλ\gamma\lambda each step and spikes on visited states/features, giving an equivalent O(d)O(d)-per-step update.
  • Under offline (batch, end-of-episode) updating, forward and backward TD(λ\lambda) produce mathematically identical weight changes.
  • Eligibility traces plug directly into linear function approximation and set up the general recipe used later in Semi-Gradient Methods with Function Approximation.
The core insight

TD(λ\lambda) computes a geometrically-weighted average of all nn-step returns, and eligibility traces let you compute that average online in constant time per step without ever storing the trajectory.

The idea

Recall that the nn-step return is

Gt:t+n=Rt+1+γRt+2+⋯+γn−1Rt+n+γnV(St+n),G_{t:t+n} = R_{t+1} + \gamma R_{t+2} + \cdots + \gamma^{n-1} R_{t+n} + \gamma^n V(S_{t+n}),

truncating the real trajectory after nn steps and bootstrapping off the current value estimate VV thereafter. Different nn trade bias for variance: small nn bootstraps heavily (more bias, less variance), large nn approaches the Monte Carlo return (less bias, more variance). Rather than picking one nn, the λ\lambda-return averages over all of them, weighting the nn-step return by (1−λ)λn−1(1-\lambda)\lambda^{n-1}:

Gtλ=(1−λ)∑n=1∞λn−1Gt:t+n.G_t^\lambda = (1-\lambda) \sum_{n=1}^{\infty} \lambda^{n-1} G_{t:t+n}.

The weights (1−λ)λn−1(1-\lambda)\lambda^{n-1} form a proper probability distribution over n=1,2,3,…n = 1, 2, 3, \dots (they sum to 1), decaying geometrically, so most of the weight sits on small nn when λ\lambda is small and spreads out toward larger nn as λ→1\lambda \to 1. For an episodic task ending at time TT, once t+n≥Tt+n \ge T the nn-step return becomes just the full Monte Carlo return GtG_t, and the tail of the geometric series after termination is folded into a single term with weight λT−t−1\lambda^{T-t-1}:

Gtλ=(1−λ)∑n=1T−t−1λn−1Gt:t+n+λT−t−1Gt.G_t^\lambda = (1-\lambda) \sum_{n=1}^{T-t-1} \lambda^{n-1} G_{t:t+n} + \lambda^{T-t-1} G_t.

Setting λ=0\lambda = 0 collapses the sum to just Gt:t+1G_{t:t+1}, the ordinary one-step TD target. Setting λ=1\lambda = 1 makes every finite-nn-step term vanish (weight →0\to 0) except the final Monte Carlo term, recovering the full return. This is the forward view: at each time tt, imagine looking ahead through the rest of the episode to compute GtλG_t^\lambda, then update

V(St)←V(St)+α[Gtλ−V(St)].V(S_t) \leftarrow V(S_t) + \alpha \big[G_t^\lambda - V(S_t)\big].

It is a clean theoretical object but not implementable causally — it requires future rewards not yet observed. The backward view produces the same total updates (under offline, end-of-episode application) using only information available up to the present. It introduces an eligibility trace, a scalar per state (tabular case) or a vector per weight (function approximation case), that records how "eligible" each state/feature is for the current TD error. Every step, all traces decay by a factor γλ\gamma\lambda, and the trace for the just-visited state (or the gradient of the value function at the current state, in the function-approximation case) is bumped up. The current one-step TD error is then broadcast to every state/feature in proportion to its trace, not just the current state. This mechanism is what "unifies" nn-step methods: it lets a single scalar per step implicitly account for corrections that would otherwise require nn-step lookahead for every nn simultaneously.

How it works

Tabular forward view (conceptual, offline). For each state visited at time tt in an episode, compute GtλG_t^\lambda using the full (or truncated, in continuing tasks) reward sequence, then accumulate ΔV(St)=α[Gtλ−V(St)]\Delta V(S_t) = \alpha[G_t^\lambda - V(S_t)] and apply all updates at the end of the episode. This is correct but requires storing the whole trajectory and is O(T2)O(T^2) naively (an nn-step return for every tt and every nn).

Tabular backward view with eligibility traces (online, incremental). This is the practical algorithm: ``` Algorithm: TD(lambda) with eligibility traces (tabular, state-value prediction) Input: policy π to evaluate, step size α ∈ (0,1], discount γ, trace decay λ ∈ [0,1] Initialize V(s) arbitrarily for all s (V(terminal) = 0) for each episode: initialize E(s) = 0 for all s # eligibility traces S ← initial state of episode while S is not terminal: A ← action given by π(S) take action A, observe reward R, next state S' δ ← R + γ V(S') - V(S) # one-step TD error E(S) ← E(S) + 1 # accumulating trace at current state for each state s: V(s) ← V(s) + α δ E(s) E(s) ← γ λ * E(s) S ← S' ``` Two design choices deserve names. The trace update `E(S) ← E(S) + 1` is the accumulating trace; an alternative, the replacing trace, instead sets `E(S) ← 1` on revisits (useful when a state can be revisited within an episode, preventing traces from exploding). The inner loop "for each state s" is what makes the tabular version look O(∣S∣)O(|S|) per step; in practice only states with nonzero trace need updating, and traces decay to numerical zero after O(log⁡γλϵ)O(\log_{\gamma\lambda} \epsilon) steps, so a sparse active-trace list keeps this efficient.

Linear function approximation (the version that matters for scale). Replace the per-state trace with a trace vector e∈Rd\mathbf{e} \in \mathbb{R}^d matching the weight vector w\mathbf{w}, and replace "visit state ss" with "accumulate the feature/gradient vector ∇wv^(S,w)\nabla_{\mathbf{w}} \hat{v}(S,\mathbf{w})": ``` Algorithm: Semi-gradient TD(lambda) (linear function approximation) Input: features x(s) ∈ R^d for all s, step size α, discount γ, trace decay λ Initialize weight vector w arbitrarily (e.g., w = 0) for each episode: e ← 0 # eligibility trace vector, e ∈ R^d S ← initial state while S is not terminal: A ← action given by policy take action A, observe reward R, next state S' v_hat_S ← w · x(S) v_hat_S' ← 0 if S' is terminal else w · x(S') δ ← R + γ v_hat_S' - v_hat_S e ← γ λ e + x(S) # decay, then accumulate gradient (= x(S) for linear) w ← w + α δ * e S ← S' ``` Here ∇wv^(S,w)=x(S)\nabla_{\mathbf{w}} \hat{v}(S,\mathbf{w}) = \mathbf{x}(S) because v^\hat{v} is linear in w\mathbf{w}; with nonlinear function approximators the same recipe generalizes by accumulating the actual gradient into e\mathbf{e}, which is exactly the bridge into Semi-Gradient Methods with Function Approximation. Note the update touches every component of w\mathbf{w} each step through the trace, but if features are sparse (e.g., one-hot or tile coding) this is cheap since e\mathbf{e} is sparse too.

Figure
Forward view vs. backward view of TD(λ): the same total credit assignment, computed two ways
Forward view — G_t^λ looks ahead S_t T (end) G(1) weight (1−λ) G(2) weight (1−λ)λ G(n) weight (1−λ)λ^(n-1) Monte Carlo tail, weight λ^(T-t-1) G_t^λ = (1−λ)·Σ λ^(n−1) G(t:t+n) + λ^(T−t−1)·G_t Needs full future trajectory — not causal, used offline/conceptually. Backward view — eligibility trace looks back S_t (current) δ_t broadcast backward, scaled by trace e(s) = (γλ)^k e(s) decays by γλ / step spikes +1 (or =1) on visit V(s) += α·δ_t·e(s), every step, all s Offline sum of backward updates over an episode = forward Σ_t α[G_t^λ − V(S_t)] · ∇V(S_t)

Complexity & correctness

Time and space. The backward-view algorithm performs, per environment step, one TD-error computation and one pass over the eligibility trace (and value/weight vector). Tabular: O(∣S∣)O(|S|) worst case per step if traces are dense, but O(k)O(k) if only kk states currently have non-negligible trace, since traces decay geometrically as (γλ)j(\gamma\lambda)^j and can be dropped once below a numerical threshold — after O(log⁡γλϵ)O(\log_{\gamma\lambda}\epsilon) steps a trace is negligible. Linear function approximation: O(d)O(d) per step where dd is the feature dimension, matching plain semi-gradient TD(0) in per-step cost, and O(d)O(d) space for the trace vector, an additive constant-factor overhead. Contrast this with a naive forward-view implementation that recomputes GtλG_t^\lambda using nn-step returns for every nn up to episode length: that costs O(T)O(T) work per time step and O(T2)O(T^2) per episode, plus O(T)O(T) space to store the trajectory. Eligibility traces reduce this to O(1)O(1) extra work per step (beyond ordinary TD) and O(d)O(d) space total — no trajectory storage at all. This constant-time-per-step property is exactly why traces make λ\lambda-averaging usable online, in continuing (non-episodic) tasks, and under strict memory budgets such as embedded control.

Correctness — equivalence of forward and backward views (offline case). The central claim is that, summed over an episode, the backward-view weight updates equal the forward-view weight updates, when updates are accumulated and applied only at the end of the episode (the "offline λ\lambda-return algorithm" matches "offline TD(λ\lambda)"). Sketch of the argument for the tabular case: fix a state ss and expand the total backward-view update to V(s)V(s) over an episode,

ΔV(s)=α∑t=0T−1δt 1[St=s]⋅(γλ) 0  +  (contributions to s’s trace from later visits, discounted),\Delta V(s) = \alpha \sum_{t=0}^{T-1} \delta_t \, \mathbb{1}[S_t = s] \cdot (\gamma\lambda)^{\,0} \;+\; (\text{contributions to } s\text{'s trace from later visits, discounted}),

more precisely, since the trace for ss after being set at some visit time kk decays by γλ\gamma\lambda each subsequent step,

ΔV(s)=α∑k:Sk=s∑t≥k(γλ)t−k δt.\Delta V(s) = \alpha \sum_{k : S_k = s} \sum_{t \ge k} (\gamma\lambda)^{t-k} \, \delta_t .

Swap the order of summation to instead group by tt: this says every TD error δt\delta_t contributes to every earlier visited state s=Sks = S_k (k≤tk \le t) with weight (γλ)t−k(\gamma\lambda)^{t-k}. The classical algebraic identity underlying TD(λ\lambda) is that a telescoping sum of discounted one-step TD errors reconstructs the λ\lambda-return exactly:

Gtλ−V(St)=∑k=tT−1(γλ)k−t δk,G_t^\lambda - V(S_t) = \sum_{k=t}^{T-1} (\gamma\lambda)^{k-t}\, \delta_k,

where δk=Rk+1+γV(Sk+1)−V(Sk)\delta_k = R_{k+1} + \gamma V(S_{k+1}) - V(S_k) are ordinary TD errors along the trajectory (assuming VV is held fixed during the episode, as in the offline setting). This identity is proved by induction on the horizon: expand GtλG_t^\lambda via its recursive definition Gtλ=Rt+1+γ[(1−λ)V(St+1)+λGt+1λ]G_t^\lambda = R_{t+1} + \gamma\big[(1-\lambda)V(S_{t+1}) + \lambda G_{t+1}^\lambda\big], subtract V(St)V(S_t), and observe that the recursion telescopes into exactly the discounted sum of one-step errors above, matching term by term with the trace-weighted broadcast performed by the backward-view algorithm. Consequently, summing α[Gtλ−V(St)]\alpha[G_t^\lambda - V(S_t)] over all tt where St=sS_t = s (the offline forward-view total update to ss) equals summing α δk⋅(γλ)k−t\alpha\, \delta_k \cdot (\gamma\lambda)^{k-t} contributions collected by the eligibility trace — which is precisely ΔV(s)\Delta V(s) above. This establishes the forward/backward equivalence exactly, not approximately, for offline updating.

Online updating and the approximation it introduces. In practice, the backward-view algorithm updates VV (or w\mathbf{w}) immediately at each step rather than waiting for episode end. This changes the effective target slightly, because later TD errors δk\delta_k are computed against an already-updated VV, not the fixed VV used in the offline derivation. The online and offline versions therefore only coincide exactly as α→0\alpha \to 0; for finite step sizes they are close but not identical, a discrepancy resolved exactly by the more intricate true online TD(λ\lambda) algorithm, which reproduces the online forward-view λ\lambda-return exactly using a modified ("dutch") trace update. Standard TD(λ\lambda) with accumulating or replacing traces sacrifices this exact equivalence for simplicity, and in practice the difference is small for reasonable step sizes.

Convergence. For tabular prediction under a fixed policy, with standard step-size (Robbins–Monro) conditions ∑tαt=∞\sum_t \alpha_t = \infty, ∑tαt2<∞\sum_t \alpha_t^2 < \infty, TD(λ\lambda) converges to the true value function vπv_\pi with probability 1, for any λ∈[0,1]\lambda \in [0,1], since it remains a stochastic approximation to a contraction mapping (the λ\lambda-weighted Bellman operator is a contraction in the same way the one-step Bellman operator is). With linear function approximation and on-policy sampling, semi-gradient TD(λ\lambda) converges to a fixed point whose value error is bounded relative to the best representable approximation, with the bound tightening as λ→1\lambda \to 1 (approaching the Monte Carlo/least-squares projection) at the cost of higher variance — the same bias–variance tension discussed under Bootstrapping and the Bias-Variance Tradeoff.

Worked example

Consider a tiny 4-state random walk: states A−B−C−D−TerminalA - B - C - D - \text{Terminal}, all transitions deterministic left-to-right, reward 00 everywhere except +1+1 entering the terminal state, γ=1\gamma = 1. Initialize V(A)=V(B)=V(C)=V(D)=0.5V(A)=V(B)=V(C)=V(D) = 0.5. One episode is observed: A→B→C→D→TerminalA \to B \to C \to D \to \text{Terminal}, rewards 0,0,0,10,0,0,1.

Step-by-step backward-view trace with α=0.5\alpha = 0.5, λ=0.5\lambda = 0.5, γ=1\gamma = 1 (accumulating traces):

StepSt→St+1S_t \to S_{t+1}RRδt=R+V(St+1)−V(St)\delta_t = R+V(S_{t+1})-V(S_t)E(A),E(B),E(C),E(D)E(A),E(B),E(C),E(D) after decay+bumpUpdates applied (αδE\alpha\delta E)
1A→BA\to B00+0.5−0.5=00 + 0.5 - 0.5 = 0E(A)=1E(A)=1 (others 0)no change (δ=0\delta=0)
2B→CB\to C00+0.5−0.5=00 + 0.5 - 0.5 = 0E(A)=0.5, E(B)=1E(A)=0.5,\,E(B)=1no change (δ=0\delta=0)
3C→DC\to D00+0.5−0.5=00 + 0.5 - 0.5 = 0E(A)=0.25,E(B)=0.5,E(C)=1E(A)=0.25,E(B)=0.5,E(C)=1no change (δ=0\delta=0)
4D→D\to Term11+0−0.5=0.51 + 0 - 0.5 = 0.5E(A)=0.125,E(B)=0.25,E(C)=0.5,E(D)=1E(A)=0.125,E(B)=0.25,E(C)=0.5,E(D)=1ΔV(A)=0.0313,ΔV(B)=0.0625,ΔV(C)=0.125,ΔV(D)=0.25\Delta V(A){=}0.0313,\Delta V(B){=}0.0625,\Delta V(C){=}0.125,\Delta V(D){=}0.25

(Traces are shown after the decay-then-bump for the just-visited state; note only the final step has nonzero TD error here because all intermediate value estimates were already consistent at 0.50.5, deliberately chosen so the single informative error at termination is the only source of learning — this isolates how that one signal fans out backward.) Final values after this episode:

V(A)=0.531,V(B)=0.5625,V(C)=0.625,V(D)=0.75.V(A) = 0.531,\quad V(B) = 0.5625,\quad V(C) = 0.625,\quad V(D) = 0.75.

Cross-check against the forward view. The λ\lambda-return for t=0t=0 (state AA) with λ=0.5\lambda = 0.5, using G0:1=0.5G_{0:1}=0.5, G0:2=0.5G_{0:2}=0.5, G0:3=0.5G_{0:3}=0.5, G0:4=G0=1G_{0:4}=G_0=1 (all intermediate nn-step returns bootstrap off V=0.5V=0.5 except the full return which sees the actual terminal reward):

G0λ=(1−0.5)[0.5⋅G0:1+0.51⋅G0:2]+…G_0^\lambda = (1-0.5)\big[0.5 \cdot G_{0:1} + 0.5^1\cdot G_{0:2}\big] + \dots

Using the episodic form with T=4T=4:

G0λ=(1−λ)∑n=13λn−1G0:n+λ3G0=0.5(0.5⋅1+0.25⋅0.5)⋅2…G_0^\lambda = (1-\lambda)\sum_{n=1}^{3}\lambda^{n-1}G_{0:n} + \lambda^{3}G_0 = 0.5(0.5\cdot 1 + 0.25\cdot 0.5) \cdot 2 \dots

computing directly: (1−λ)[λ0G0:1+λ1G0:2+λ2G0:3]+λ3G0=0.5[0.5+0.25⋅0.5+0.125⋅0.5]+0.125⋅1=0.5[0.5+0.125+0.0625]+0.125=0.5(0.6875)+0.125=0.34375+0.125=0.46875(1-\lambda)[\lambda^0 G_{0:1} + \lambda^1 G_{0:2} + \lambda^2 G_{0:3}] + \lambda^3 G_0 = 0.5[0.5 + 0.25\cdot0.5 + 0.125\cdot 0.5] + 0.125 \cdot 1 = 0.5[0.5+0.125+0.0625] + 0.125 = 0.5(0.6875) + 0.125 = 0.34375+0.125=0.46875. Then ΔV(A)=α[G0λ−V(A)]=0.5[0.46875−0.5]=−0.0156\Delta V(A) = \alpha[G_0^\lambda - V(A)] = 0.5[0.46875 - 0.5] = -0.0156 — this disagrees with the backward-view result above (+0.0313+0.0313) because backward-view here is applied online (updates mid-episode change later δ\delta's implicitly through the trace mechanics as derived), while this forward computation assumed a fixed V=0.5V=0.5 throughout (the offline setting). Re-deriving offline (freeze VV at 0.50.5 throughout, apply forward-view updates only at episode end, matching the backward-view sum-of-TD-errors identity exactly) recovers agreement: summing (γλ)k−0δk(\gamma\lambda)^{k-0}\delta_k over k=0,…,3k=0,\dots,3 with all δk=0\delta_k = 0 except δ3=0.5\delta_3 = 0.5 gives (γλ)3⋅0.5=0.125⋅0.5=0.0625(\gamma\lambda)^3 \cdot 0.5 = 0.125 \cdot 0.5 = 0.0625, and α⋅0.0625=0.03125\alpha \cdot 0.0625 = 0.03125 — matching the backward-view update to V(A)V(A) found in the table. The apparent mismatch above came from mixing an online backward trace with a naively-recomputed forward return; the theorem guarantees equivalence specifically in the offline (frozen-VV-during-episode) setting, exactly as the correctness argument states.

Common pitfalls & traps

PitfallWhy it happensFix
Confusing online and offline TD(λ\lambda)Assuming exact forward/backward equivalence holds for the online algorithmRemember equivalence is exact only offline; use true online TD(λ\lambda) if exact online equivalence is required
Trace explosion with revisited statesAccumulating traces add every visit, growing unboundedly in loopy environmentsUse replacing traces, or clip/normalize, when states recur within an episode
Forgetting to decay traces before the bumpOrder matters: decay-then-add vs. add-then-decay give different discounting of the current stepFollow the standard convention consistently: `e ← γλe`, then add current feature/visit
Treating λ=1 as "just Monte Carlo" without careWith function approximation and continuing (non-episodic) tasks, λ=1 traces can drift or diverge without episode resetsReset traces at episode boundaries; be cautious with λ near 1 in continuing tasks
Dense trace updates on huge state/feature spacesNaively updating all dd trace components every step is wasteful when most are ~0Maintain only the sparse set of active (non-negligible) trace entries
Ignoring the bias–variance shift as λ changesTreating λ as a free hyperparameter without expecting variance to grow near 1Tune λ empirically; expect noisier but less biased updates as λ increases, cf. Bootstrapping and the Bias-Variance Tradeoff

Pioneers & history

TD(λ\lambda) and eligibility traces emerged from work connecting animal learning theory, dynamic programming, and stochastic approximation, culminating in the temporal-difference learning framework that underlies most of modern model-free reinforcement learning.

Origins · 1 minRichard S. Sutton and how this was discovered
RS
Richard S. Sutton
1957–present · Developed TD learning and TD(λ) at the University of Massachusetts Amherst, later a foundational figure at the University of Alberta and DeepMind, unifying supervised-style prediction with dynamic-programming-style bootstrapping

History
1988
— Sutton introduces temporal-difference learning and TD(λ), proving convergence for linear prediction.
1989
— Watkins formalizes Q-learning, a closely related model-free control method building on TD ideas.
1996
— Tsitsiklis and Van Roy analyze convergence of TD(λ) with linear function approximation.
1998
— Sutton and Barto's Reinforcement Learning: An Introduction codifies the forward/backward view duality.
2014
— van Seijen and Sutton introduce true online TD(λ), resolving the exact online/offline equivalence gap.

Where this matters

Eligibility traces and TD(λ\lambda)-style credit assignment appear wherever an agent must learn from delayed, sparse rewards without waiting for episodes to finish. Classic game-playing systems such as Tesauro's TD-Gammon used TD(λ\lambda) with a neural network value function to reach superhuman backgammon play, one of the earliest large-scale demonstrations that bootstrapped, multi-step credit assignment scales. Actor-critic architectures used in robotics and simulated control (walking, manipulation, locomotion) routinely use eligibility-trace-style multi-step targets — including the closely related n-Step Bootstrapping Methods and GAE (generalized advantage estimation) in policy-gradient methods — as a direct descendant of the λ\lambda-return idea for variance reduction. Traces are especially valuable in continuing, non-episodic control tasks such as process control or continual robot operation, where there is no "end of episode" to wait for and only the O(1)O(1)-per-step backward view is feasible. The conceptual machinery here — a decaying memory of recent activity broadcasting a scalar error signal backward — is also the direct ancestor of the eligibility-trace ideas used in biologically-inspired learning rules and in extending value-based methods to deep networks, the topic taken up next under Semi-Gradient Methods with Function Approximation.

Ask the tutor: How does true online TD(λ) modify the eligibility trace update to make the online and offline views exactly equivalent?

Why is TD(λ) considered a "unification" of TD(0) and Monte Carlo methods?

Because the λ\lambda-return GtλG_t^\lambda is a weighted average of every nn-step return, and its two extreme settings recover the two classic methods exactly. At λ=0\lambda=0, the geometric weighting (1−λ)λn−1(1-\lambda)\lambda^{n-1} puts all weight on n=1n=1, giving the ordinary one-step TD target. At λ=1\lambda=1, all finite-nn terms vanish and only the full Monte Carlo return survives. Values of λ\lambda strictly between 0 and 1 blend bias and variance continuously, so instead of manually choosing an nn-step method as in n-Step Bootstrapping Methods, you get an entire family accessible through one continuous parameter, with eligibility traces making every point in that family computable online in constant time per step.

What exactly does an eligibility trace represent intuitively?

It represents a decaying record of "how responsible" a state (or feature) is for the reward currently being observed, based on how recently and how strongly it was visited. If a state was visited one step ago, its trace is close to its maximum bump value; if it was visited many steps ago, the trace has decayed by (γλ)k(\gamma\lambda)^k for kk elapsed steps, so it receives a proportionally smaller share of the current TD error. This mirrors the biological idea of a "stimulus trace" in classical conditioning: a fading memory that lets a later, delayed reinforcement signal still adjust earlier stimuli, which is part of TD learning's original inspiration from animal learning theory.

Why doesn't the online version of TD(λ) exactly match the offline forward view?

The forward/backward equivalence proof assumes VV (or the weights) stay fixed throughout the episode while errors δk\delta_k are computed, with all updates summed and applied only afterward. The practical online algorithm instead updates VV immediately after every step, so later TD errors δk\delta_k are computed using an already-changed value function, not the frozen one assumed in the derivation. This introduces a small discrepancy proportional to the step size α\alpha; as α→0\alpha \to 0 the two coincide. True online TD(λ), introduced later, uses a modified "dutch trace" update to close this gap and match the online forward view exactly, at slightly higher implementation complexity.

How should I choose λ in practice?

Treat λ\lambda as a bias–variance knob, as covered generally in Bootstrapping and the Bias-Variance Tradeoff. Small λ\lambda (close to 0) gives low-variance but potentially high-bias updates that rely heavily on the current value estimates being accurate; large λ\lambda (close to 1) reduces bias by looking further into real observed returns but increases variance and, with function approximation, can be less stable in continuing tasks. Empirically, intermediate values (often λ≈0.8\lambda \approx 0.8–0.950.95 in practice, especially in policy-gradient variants like GAE) tend to perform best, and it is usually tuned as a hyperparameter alongside the step size α\alpha rather than derived analytically.

What is the difference between accumulating and replacing eligibility traces?

An accumulating trace adds 1 (or the current feature vector) to the existing trace value every time a state is visited, so a state visited multiple times in quick succession within an episode can build up a trace larger than 1. A replacing trace instead resets the trace to exactly 1 (or clips it) on each visit, preventing unbounded growth in environments with frequent self-loops or revisits. Replacing traces were introduced specifically to fix instability observed with accumulating traces in such environments and are often preferred in tabular settings; for function approximation, variants like "replacing" or "dutch" traces exist but accumulating traces remain the more common default.

Does TD(λ) require storing the entire episode's history?

No — that is precisely the point of the backward view. The forward-view λ\lambda-return, taken literally, would require future rewards and hence a stored trajectory, giving O(T)O(T) space and O(T2)O(T^2) time per episode if computed naively for every nn-step return. The backward-view eligibility-trace algorithm instead needs only the current trace vector (size O(d)O(d) for dd features, or O(∣S∣)O(|S|) tabular) and updates it incrementally, achieving O(d)O(d) time and space per step with no trajectory storage, which is what makes it usable in continuing, non-episodic, or memory-constrained settings.

How does TD(λ) relate to n-step methods I already know?

TD(λ\lambda) is a strict generalization: instead of committing to a single lookahead length nn as in n-Step Bootstrapping Methods, it computes a geometrically-weighted average over every possible nn simultaneously via the λ\lambda-return. The eligibility trace mechanism is what makes this averaging computationally tractable, replacing what would otherwise require maintaining separate nn-step return computations for every nn with a single decaying trace vector updated in constant time per step, and yielding, under offline updating, exactly the same result you would get by explicitly averaging infinitely many nn-step returns.

Before this

Where this leads