One-Line Summary: Credit assignment mechanism that blends TD and Monte Carlo through exponentially decaying memory of visited states.

Prerequisites: temporal-difference-learning.md, monte-carlo-methods.md, return-and-discount-factor.md.

What Are Eligibility Traces?

Imagine you're training a dog. The dog performs a sequence of tricks -- sit, shake, roll over -- and you give it a treat at the end. Which trick earned the treat? The most recent one (roll over) deserves the most credit, but the earlier ones contributed too. You might assign decreasing credit backward through time: roll over gets the most, shake gets some, and sit gets a little.

Eligibility traces implement exactly this idea in RL. They maintain a decaying memory of which states were recently visited, so when a reward signal arrives (via the TD error), credit is distributed backward to all recently visited states -- not just the immediately preceding one. This bridges the gap between TD learning (which updates only one step back) and Monte Carlo methods (which wait until the episode ends).

How It Works

The Forward View: -Return

The -return is a weighted average of all -step returns:

where is the -step return.

The geometric weighting sums to 1, creating a valid average. This smoothly interpolates:

  • : Only the 1-step return -- equivalent to TD(0)
  • : The full Monte Carlo return (no bootstrapping)
  • : A blend, with exponentially decreasing weight on longer returns

The Backward View: Eligibility Traces

Computing the -return in the forward view requires waiting until the end of the episode. The backward view achieves the same result incrementally using eligibility traces.

Each state has an eligibility trace that tracks how recently and frequently state was visited:

Accumulating traces:

Replacing traces:

The trace decays by at each step and gets a boost when the state is visited. Replacing traces cap the trace at 1 upon revisiting, preventing inflated updates in loops.

TD() Algorithm

At each time step:

  1. Observe transition
  2. Compute TD error:
  3. Update trace: for all states
  4. Update all state values: for all

The key insight: the same TD error is used to update every state, but weighted by its eligibility trace. States visited long ago have decayed traces and receive small updates. The state just visited has a trace near 1 and receives the full update.

SARSA() and Q()

Eligibility traces extend naturally to control:

SARSA(): Maintain traces over state-action pairs :

Watkins's Q(): Combines Q-learning with traces, but cuts the trace to zero whenever a non-greedy action is taken (because Q-learning is off-policy, and the trace should only credit the greedy path):

The Equivalence

Sutton & Barto (2018) prove that the forward view (-return) and backward view (eligibility traces) produce identical total updates over an episode (for the offline/batch case). The backward view is computationally preferable because it updates incrementally at each step.

Why It Matters

Eligibility traces provide a unifying framework for TD and Monte Carlo methods. Rather than choosing between TD(0) (low variance, high bias) and Monte Carlo (high variance, zero bias), the practitioner can tune to find the optimal bias-variance trade-off for their problem.

In practice, intermediate values (0.8-0.95) often outperform both extremes. Traces propagate reward information faster than TD(0) without waiting for full episodes like Monte Carlo, making learning significantly more sample-efficient in many environments.

Key Technical Details

  • Computational cost: TD() requires storing and updating a trace for every state (or state-action pair) at each step, making it per step instead of for TD(0). This motivated truncated traces and sparse implementations.
  • Common values: 0.8-0.95 typically works best. is a common default.
  • Replacing vs accumulating traces: Replacing traces often work better in practice, especially in environments with loops or repeated state visits. Singh & Sutton (1996) showed replacing traces can be significantly faster.
  • In deep RL, eligibility traces are less commonly used because experience replay (which randomly samples transitions) breaks the temporal structure that traces rely on. GAE (Generalized Advantage Estimation) is the modern equivalent, computing -weighted advantages for policy gradient methods.
  • GAE connection: The Generalized Advantage Estimation used in PPO and A2C is mathematically equivalent to using a -return for advantage estimation:

Common Misconceptions

  • "Eligibility traces are just a historical curiosity." While less prominent in modern deep RL, the -return idea lives on as GAE, which is central to PPO and modern policy gradient methods. Understanding traces is essential for understanding GAE.
  • " is always equivalent to Monte Carlo." This is true only for episodic tasks. For continuing tasks, can cause issues because traces never fully decay.
  • "Traces require storing all visited states." In practice, traces below a threshold can be zeroed out (sparse traces), and only recently visited states need active traces.
  • "The backward view is an approximation." It produces identical total updates to the forward view over a complete episode (Sutton & Barto, 2018, Chapter 12).

Connections to Other Concepts

  • temporal-difference-learning.md -- TD(0) is the special case .
  • monte-carlo-methods.md -- Monte Carlo is the special case .
  • n-step-methods.md -- -step returns are individual components of the -return mixture.
  • advantage-estimation.md -- GAE is the modern descendant of eligibility traces for policy gradient methods.
  • q-learning.md -- Q() extends Q-learning with traces but requires trace-cutting for off-policy correctness.

Further Reading

  1. Sutton & Barto (2018) -- Reinforcement Learning: An Introduction, Chapter 12. Definitive treatment of eligibility traces, forward/backward equivalence, and practical variants.
  2. Singh & Sutton (1996) -- "Reinforcement learning with replacing eligibility traces." Machine Learning. Demonstrates the advantages of replacing over accumulating traces.
  3. Schulman et al. (2016) -- "High-dimensional continuous control using generalized advantage estimation." ICLR. The modern application of -weighted returns as GAE for policy gradients.
  4. van Seijen et al. (2016) -- "True Online TD()." JMLR. An improved online implementation that exactly matches the forward-view -return update at every step, not just in aggregate.