Concepts / Introduction to n-Step TD Methods

Introduction to n-Step TD Methods

For a five-step method, the relevant update is delayed by five time steps when five future steps are available.

  • Programming

A Deliberate Middle Ground

When a learner estimates the value of a state, it must decide how much future experience to use. A one-step TD method uses the next event quickly. A Monte Carlo method waits for the return through the end of the episode. An n-step TD method chooses an intermediate amount of lookahead: it uses the next n rewards, states, and actions, then estimates what comes after them. This makes n-step methods a middle ground based on intermediate bootstrapping.

Key point

The central design choice is n. Increasing n means using more observed future rewards before relying on a value estimate for the remaining future.

Building the n-Step Return

The full return for a state at time t is the complete discounted reward sequence from time t through the end of the episode. An n-step return truncates that sequence after n steps. The first n rewards are included explicitly because the learner has observed them. The value estimate for the state reached after those n steps represents the missing later terms. That estimate is discounted by γ^n, so the later portion contributes less according to the same discounting position it would have in the return.

State at tstarting pointReward at t+1explicitReward at t+2explicitReward at t+nexplicitValue at t+nbootstrapped and discountedby γ^nLater rewardsrepresented by estimatelook aheadthenthrough n stepsestimate at boundarystands in for
Which rewards are included explicitly, and where does the estimated value replace the missing later rewards?
Worked example

Separating observed and estimated parts

A learner is evaluating the state at time t with a three-step return.

  1. 1
    Observe three rewards

    The learner follows the experience through the next three time steps and records the rewards encountered at t+1, t+2, and t+3.

  2. 2
    Stop the explicit sequence

    The n-step return stops adding directly observed rewards after the third step.

  3. 3
    Use the boundary estimate

    The value estimate for the state reached at t+3 represents the later reward terms that have not been included explicitly. Its contribution is discounted by γ^3.

Result

The three-step return is an approximation to the full return: it contains three explicit rewards followed by a discounted estimate of the remaining future.

Following One State Forward

Consider the state occupied at time t. An n-step method must follow the experience far enough to collect the next n rewards, states, and actions. Only when those required future events are available can the estimate for the earlier state be updated. The result is a delay of n time steps between the earlier state and its update, except when the episode terminates sooner.

State at tupdate pendingStep t+1future experienceStep t+nrequired lookaheadUpdate at tafter n future stepsEpisode terminationmay occur before nShorter availablereturnepisode has endedwaitcontinueenough experienceepisode may endbefore n steps
When can the value at time t be updated after looking ahead n steps, and what changes near episode termination?
Before

State at time t is reached. No future sequence is available yet.

The update is pending.

After

The next n rewards, states, and actions are available. The estimate for the state at time t can now be updated.

The n-step return can be formed.

Near episode termination, the learner may not have n future steps available. In that case, the episode ends before the planned lookahead is complete, so the available reward sequence reaches termination sooner. The n-step return then contains the complete remaining sequence rather than waiting for nonexistent future steps.

The Full-Return Boundary

An n-step return equals the ordinary full return when the episode terminates within the chosen n-step lookahead. There are no later terms left to estimate beyond the point of termination. The return therefore includes the entire remaining discounted reward sequence, making the bootstrapped replacement unnecessary.

n-step targetexplicit rewards plusboundary estimateFull returnentire remaining sequenceLater rewardsnot yet includedEpisode terminationoccurs within n stepswould normally estimatereturn reaches
Under what condition does the n-step return include the entire remaining reward sequence?
Worked example

Termination before the lookahead limit

Suppose the selected n is larger than the number of remaining steps in the episode.

  1. 1
    Start at time t

    The learner begins forming an n-step return for the state at time t.

  2. 2
    Reach termination early

    The episode ends before n future steps have passed.

  3. 3
    Use every remaining reward

    Because the episode has ended, the return contains the complete remaining discounted reward sequence. There are no later terms requiring a value estimate.

Result

The n-step return is equal to the ordinary full return whenever termination occurs within the chosen lookahead.

Choosing the Amount of Lookahead

The position of an n-step method can be understood by comparing how much it observes with how much it bootstraps. A one-step method uses the next event and therefore updates with a short lookahead. A Monte Carlo method uses the full return through episode termination and does not need the same intermediate cutoff. An n-step method uses more than one immediate event but stops before the full return when the episode continues beyond n steps.

One-step TDshort lookaheadObserved rewardsincreases with nn-step TDintermediate lookaheadBootstrappingboundary estimateMonte Carlofull returnEpisode waitingfull-return delayincrease napproach full lookaheaduses feweruses intermediatewaits through termination
How does increasing n change the balance between observed rewards, bootstrapping, and waiting for episode termination?
ApproachFuture information usedBootstrapping positionUpdate timing
One-step TDThe next eventUses a short-step value estimateCan use the next event quickly
n-step TDThe next n rewards, states, and actionsUses a value estimate after those n stepsWaits n future steps, unless termination occurs sooner
Monte CarloThe complete return through episode terminationDoes not stop at an intermediate n-step boundaryWaits for the longer return

The table shows the conceptual position of n-step methods between short-lookahead TD methods and full-return methods.

Resource Costs of Waiting

Looking farther ahead has practical costs. Updates are delayed because the method must wait for n future time steps. Each time step requires more computation than the earlier methods discussed in the chapter because the method handles a longer sequence. An implementation also needs more memory than a one-step method to retain states, actions, rewards, and sometimes other variables from the last n time steps.

Recent stateslast n time stepsPending updatestate at earlier timeRecent actionslast n time stepsRecent rewardslast n time stepsOther variableswhen requiredsupportssupportsforms returnmay support
What rewards, states, and pending updates must be retained while the method waits for enough future experience?
  • Update delay: the estimate for an earlier state waits for the required future steps.
  • Computation: each time step involves more work than the earlier one-step methods discussed in the chapter.
  • Memory: recent states, actions, rewards, and sometimes other variables must be retained for the last n time steps.

Eligibility Traces Later

Eligibility traces are presented as a later way to implement multi-step TD methods. Their role is to connect recent states to later rewards so that multiple prior states can be updated. This addresses the storage and computation challenge created by explicitly retaining a recent sequence for multi-step learning. The source also notes that eligibility traces do not remove every cost: some additional computation beyond one-step methods remains. The detailed treatment belongs to a later chapter, so the key connection here is that eligibility traces offer a more resource-efficient implementation approach.

Recent state 1eligibleEligibility tracesconnect recent statesLater rewardarrives after statesMultiple stateupdatesmulti-step effectRecent state 2eligibleRecent state 3eligibleconnected byconnected byconnected bylinks tosupports
How do eligibility traces connect recent states to later rewards so that multiple prior states can be updated?

Check Your Understanding

MEDIUM

A learner uses a four-step TD method to evaluate a state at time t. The episode continues beyond t+4. Identify which part of the return is observed directly, which part is represented by a value estimate, when the update can occur, and why the method is neither a one-step TD method nor a full-return Monte Carlo method.

Hints
  • Count the four future rewards beginning after time t.
  • The value estimate is associated with the state reached after the fourth step.
  • The update waits until the required future experience is available.
  • Compare the four-step boundary with the immediate boundary of one-step TD and the episode-ending boundary of Monte Carlo.
  • Common mistake

    Treating the n-step return as a completely different target from the full return.

    What it looks like

    Assuming that an n-step method ignores the later reward sequence.

    Why it fails

    The n-step return approximates the full return. It includes the first n observed rewards and uses a value estimate to represent the missing later terms.

    Do this instead

    Think of the n-step return as a truncated full return completed by bootstrapping.

  • Common mistake

    Assuming that every n-step return always uses exactly n rewards.

    What it looks like

    Expecting four explicit rewards even when the episode ends after two remaining steps.

    Why it fails

    Near termination, the episode may end before n future steps are available.

    Do this instead

    Use the complete remaining reward sequence when termination occurs within the selected lookahead.

  • Common mistake

    Forgetting the update delay.

    What it looks like

    Trying to update the state at time t immediately when a four-step method has only observed the next event.

    Why it fails

    The method needs the required future rewards, states, and actions before forming the four-step return.

    Do this instead

    Expect the update after four future steps when those steps exist, with earlier termination handled separately.

  • Common mistake

    Calling n-step TD a Monte Carlo method because it uses several rewards.

    What it looks like

    Concluding that any method using more than one reward must wait for episode termination.

    Why it fails

    n-step TD stops after n steps and uses a value estimate for the remaining future when the episode continues.

    Do this instead

    Classify the method by its intermediate bootstrapping boundary, not merely by the number of observed rewards.

Key Takeaways

  1. 1
    The full return contains the complete discounted reward sequence through episode termination.
  2. 2
    An n-step return includes the next n observed rewards and uses a value estimate at the n-step boundary for the missing later terms, discounted by γ^n.
  3. 3
    If the episode terminates within n steps, the n-step return includes the entire remaining sequence and equals the ordinary full return.
  4. 4
    N-step methods sit between one-step TD and Monte Carlo methods because they use intermediate bootstrapping.
  5. 5
    Looking ahead n steps delays updates and increases computation and memory requirements; eligibility traces are a later, more resource-efficient implementation approach for multi-step TD methods.

At a glance

  • The full return follows discounted rewards all the way to episode termination.
  • The n-step return explicitly observes n rewards, then bootstraps from a value estimate for the later terms.
  • Termination before n steps makes the n-step return equal to the full return.
  • N-step TD methods trade additional lookahead, computation, memory, and update delay for a position between one-step TD and Monte Carlo methods.
  • Eligibility traces later provide a more resource-efficient way to implement multi-step TD learning.

Related concepts

More concepts starting with I