Computer Engineering is coming soon

We're still writing and reviewing the notes for every subject, and we'll open it when every subject is ready. Meanwhile you can practise aptitude, ask Aria about any subject, or see the branches that are ready.

n-step bootstrapping

n-step bootstrapping is a family of temporal-difference prediction methods that interpolate between one-step TD (bootstrapping) and Monte Carlo (full-return) updates using n-step returns, useful for faster and more stable value estimation in reinforcement learning.

Drafted with Aria, reviewed by the AiCanCode.org team · Updated . How we write and check our notes. Spotted an error? Use Give Feedback at the bottom of the page.

Why it matters

n-step bootstrapping is used by engineers when they need faster learning than Monte Carlo but less bias than single-step TD. It is widely used in model-free prediction and forms the basis for algorithms (and for intuition) behind eligibility traces and TD(λ), actor–critic methods, and many deep-RL algorithms.

Key ideas

Start by defining the environment terms you will see.

  • Markov decision process (MDP): a tuple (S, A, P, R, γ) where S is the set of states, A is the set of actions, P gives transition probabilities, R gives expected rewards, and γ in [0,1] is the discount factor. (We will refer to other topics for full MDP theory.)
  • Policy (π): a mapping from states to a distribution over actions. When we write E_π we mean expectation when actions are chosen by policy π.
  • Return (full return): the (discounted) sum of future rewards from time t: G_t = R_{t+1} + γR_{t+2} + γ^2R_{t+3} + ···. It has the same units as the reward signal (often dimensionless in RL problems).
  • Value function (v_π): v_π(s) = E_π[G_t | S_t = s], the expected return under policy π starting from state s.
  • Bootstrapping: an update that uses an existing value estimate to help compute a new estimate (for example, using V(S_{t+1}) as part of the target for V(S_t)). When an algorithm uses its own current estimates as part of the target, we call that bootstrapping.
  • n-step return (G_t^{(n)}): the target that uses the first n rewards exactly and then bootstraps from the estimate at S_{t+n}: G_t^{(n)} = R_{t+1} + γ R_{t+2} + ... + γ^{n-1} R_{t+n} + γ^n V(S_{t+n}). (If S_{t+n} is terminal, V(S_{t+n}) is defined as 0.)
  • n-step bootstrapping (n-step TD prediction): update V(S_t) toward G_t^{(n)} with a step-size α (0<α≤1). For action-values (control), the on-policy analogue is n-step Sarsa with target G_t^{(n)} = ∑{k=0}^{n-1} γ^k R{t+k+1} + γ^n Q(S_{t+n}, A_{t+n}); off-policy variants require importance sampling (per-decision ratios) or use tree-backup/Expected Sarsa to reduce variance: V(S_t) <- V(S_t) + α (G_t^{(n)} - V(S_t)).

Exact statements and relationships universities ask for:

  1. Special cases: n=1 gives one-step TD (TD(0)) because G_t^{(1)} = R_{t+1} + γ V(S_{t+1}). n → ∞ (for episodic problems) gives the Monte Carlo return because the bootstrapped term γ^n V(S_{t+n}) goes away at episode end and the return becomes the full-sum of rewards.
  2. Consistency property (exact statement): If the current value function V equals the true value v_π, then for any n ≥ 1 and any state s, E_π[G_t^{(n)} | S_t = s] = v_π(s). Assumption: V = v_π exactly and expectations are under π. Proof: replace V(S_{t+n}) by v_π(S_{t+n}) and take expectations; the RHS telescopes to v_π(s) by the definition of v_π.
  3. Error decomposition: The error of using G_t^{(n)} as a target has two components: (i) variance from sampling the n rewards, and (ii) bias from using V(S_{t+n}) which may not equal v_π(S_{t+n}). Increasing n reduces bootstrap bias (because you use more real rewards) but increases variance and delay of update.

Derivation universities commonly ask for (step-by-step): show that the full-return G_t can be written as a sum of n-step returns or that TD(λ) is a geometrically weighted average of n-step returns.

  • Derive the λ-return (forward view): define λ in [0,1]. The λ-return is G_t^{λ} = (1 - λ) sum_{n=1}^{∞} λ^{n-1} G_t^{(n)}. This is a weighted average of n-step returns; as λ→0 we get G_t^{(1)} (TD(0)), as λ→1 in episodic case we approach the Monte Carlo return. The usual exam derivation: expand the infinite sum, substitute G_t^{(n)} definitions, rearrange terms to see weights on rewards and on bootstrapped terms; show convergence for 0 ≤ λ < 1; in episodic tasks argue that the limit as λ → 1 equals the Monte Carlo return.

What to draw (diagram): Draw a horizontal time-line with discrete time points t, t+1, t+2, ... up to t+n. Mark states S_t, S_{t+1}, ..., S_{t+n} and immediate rewards R_{t+1}, ..., R_{t+n}. Draw an arrow from S_{t+n} to the value V(S_{t+n}) labelled with γ^n. Annotate G_t^{(n)} as the sum of the labelled terms. For explaining λ-return draw multiple such timelines for n=1,2,3 with weights (1-λ)λ^{n-1} and show how they combine.

Formulas

Each formula is on its own line. After the formula, explain symbols, SI unit, and when it applies. G_t = R_{t+1} + γ R_{t+2} + γ^2 R_{t+3} + ...

  • R_{t+k}: reward at time t+k; units: same as the defined reward (often dimensionless). γ: discount factor (unitless). Applies to continuing tasks with 0 ≤ γ < 1 (guarantees convergence of the infinite sum), or to episodic tasks up to the terminal state (γ may be 1). v_π(s) = E_π[ G_t | S_t = s ]
  • v_π(s): value of state s under policy π; units: same as the reward. E_π: expectation under policy π. Applies for any policy π. G_t^{(n)} = R_{t+1} + γ R_{t+2} + ... + γ^{n-1} R_{t+n} + γ^n V(S_{t+n})
  • G_t^{(n)}: n-step return (target); units: same as the reward. V(S_{t+n}): current estimate of value at S_{t+n}. Applies for n ≥ 1; if S_{t+n} terminal then V(S_{t+n}) = 0. V(S_t) <- V(S_t) + α (G_t^{(n)} - V(S_t))
  • α: step-size (learning rate), 0 < α ≤ 1, unitless. Applies to incremental n-step TD prediction update. G_t^{λ} = (1 - λ) sum_{n=1}^{∞} λ^{n-1} G_t^{(n)}
  • λ: trace-decay parameter in [0,1], unitless; use 0 ≤ λ < 1 in this weighted-sum form. In episodic tasks, interpret λ = 1 as the limit λ → 1, which yields the Monte Carlo return. Applies for episodic tasks or bounded, discounted continuing tasks where returns are finite.

Worked examples

Example 1 — numeric n-step update (episodic, short episode). Problem data: γ = 0.9, α = 0.1. Episode: S0 ->(R1=1)-> S1 ->(R2=2)-> terminal (S2 terminal). Initial estimates: V(S0) = 0.5, V(S1) = 0.8, V(terminal)=0. Compute 1-step and 2-step returns from time t=0 and show updates. 1-step return G_0^{(1)} = R1 + γ V(S1) = 1 + 0.9·0.8 = 1 + 0.72 = 1.72. Update: V(S0) <- 0.5 + 0.1(1.72 - 0.5) = 0.5 + 0.1·1.22 = 0.5 + 0.122 = 0.622. Final: V(S0) = 0.622. 2-step return G_0^{(2)} = R1 + γ R2 + γ^2 V(S2) = 1 + 0.9·2 + 0.9^2·0 = 1 + 1.8 + 0 = 2.8. Update: V(S0) <- 0.5 + 0.1(2.8 - 0.5) = 0.5 + 0.1·2.3 = 0.5 + 0.23 = 0.73. Final: V(S0) = 0.73. Comment: the 2-step return used actual reward at t+2 and bootstrapped only at terminal (0), so it gave a larger target here and a larger update.

Example 2 — show interpolation and convergence to Monte Carlo. Episode: S0 -> R1=1 -> S1 -> R2=0 -> S2 terminal. γ = 0.9. True Monte Carlo return from t=0: G_0 = 1 + 0.9·0 = 1. Compute G_0^{(1)} using V(S1)=0.5 and G_0^{(2)} with V(terminal)=0. G_0^{(1)} = 1 + 0.9·0.5 = 1 + 0.45 = 1.45. G_0^{(2)} = 1 + 0.9·0 + 0.9^2·0 = 1. As n increases (n=2 here equals full MC), G_0^{(n)} moves from the one-step bootstrapped target 1.45 toward the Monte Carlo 1.0. This shows: n-step targets interpolate between TD(0) (biased by V estimates) and Monte Carlo (higher variance but unbiased with respect to V).

Example 3 — short derivation question (theory model answer): Show that if V = v_π then E_π[G_t^{(n)} | S_t = s] = v_π(s). Solution outline: Start from definition G_t^{(n)} = sum_{k=0}^{n-1} γ^k R_{t+k+1} + γ^n V(S_{t+n}). Take expectation under π conditional on S_t=s and substitute V = v_π. The expected sum of rewards plus γ^n E[v_π(S_{t+n}) | S_t=s] equals by definition the expected infinite sum v_π(s). Thus the equality holds. (Write the telescoping steps on answer sheet for full marks.)

Common mistakes

  • Not carrying through powers of γ correctly, especially when computing γ^n V(S_{t+n}).
  • Thinking larger n is always better — exam answers should mention the bias–variance tradeoff and update delay.
  • Confusing n-step returns with eligibility traces: exams often require to state that TD(λ) is a weighted average of n-step returns (forward view) and that an equivalent backward view uses eligibility traces under online updates; but specifying the equivalence conditions matters (e.g., linear function approximation, appropriate bookkeeping).

For your exam

Typical question types:

  • Definitions and short notes: define n-step return, bootstrapping, and explain bias–variance tradeoff.
  • Derivations: derive the n-step return formula, show special cases (n=1, n→∞), derive the λ-return as a weighted sum of n-step returns.
  • Numericals: compute G_t^{(n)} and one update for given rewards, γ, α, and initial V-values. Show all arithmetic with units consistent with the reward definition (often dimensionless).
  • Diagrams: draw a timeline of states, rewards, and the bootstrapped value term; label powers of γ and the target.
  • Theory proofs: prove that if V = v_π then E[G_t^{(n)} | S_t=s] = v_π(s), or show how the forward view λ-return equals the backward view with eligibility traces (state the assumptions). What a full-marks answer includes:
  • Clear definitions of terms used.
  • The general formula for G_t^{(n)} and the update step; special cases n=1 and n→∞ explicitly shown.
  • For derivations: every algebra step, mention assumptions (episodic vs continuing, V(terminal)=0), and a final clean boxed result.
  • For numericals: display intermediate arithmetic and final value with correct significant figures.

Quick check

  1. State the formula for the 3-step return G_t^{(3)}.
  2. What does n-step bootstrapping approach when n → ∞ in an episodic task?
  3. Give one advantage and one disadvantage of increasing n. Answers: 1. G_t^{(3)} = R_{t+1} + γR_{t+2} + γ^2 R_{t+3} + γ^3 V(S_{t+3}). 2. It approaches the Monte Carlo full return (no bootstrapping). 3. Advantage: less bootstrap bias; Disadvantage: higher variance and slower (delayed) updates.

Finished this topic? Mark it so your progress, study plan and readiness keep up.

Stuck on something here?