Log inStart free
LESSON 15.C4 · 6 STAGES · 3 CONTROLS · 3 CHECKSPRO · PREVIEW

MC vs TD vs n-step — the bias–variance of returns

One random walk, three targets: see each one trade bias against variance.


Pro lesson. Stage 1 is free to watch. Pro opens all 6 stages, 3 controls and 3 checks, in this lesson and every other.

Go Pro · $8.25/mo
EXPLAINER · 15.C4 · RETURNS BAYTD 0.45 · 4-STEP 0.33 · MC 0.43
01
Stage 1 of 6 · Three targets
Each row reads real moves, then the guess V. TD reads 1 move, the 4-step return reads 4, MC reads all 9.
Explain it simply

The top strip is episode 1, a walk from C to the right end. Each row builds a target for the value of C. The TD row uses one real move, then trusts the guess for the next state. The Monte Carlo row waits for the end and uses no guess.

Episode 1 is C B A B C B C D E, then the right end. The TD target is 0.450, the 4-step return is 0.328 and the MC return is 0.430.

states of the walktargets, means and the guess Vbias, variance and errorstep size αtrue value
three targets for CCt0Bt1At2Bt3Ct4Bt5Ct6Dt7Et8+1right end0.500 + 0.9·V(B) = 0.900·0.500 = 0.4500.500 + 0.9⁴·V(C) = 0.656·0.500 = 0.328+1 after 9 moves: 0.9⁸ = 0.430TD targetlesson 15.20G = 0.454-step returnlesson 15.23G = 0.33MC returnlesson 15.19G = 0.43three targets for CCt0Bt1At2Bt3Ct4Bt5Ct6Dt7Et8+1right end0.500 + 0.9·V(B) = 0.900·0.500 = 0.4500.500 + 0.9⁴·V(C) = 0.656·0.500 = 0.328+1 after 9 moves: 0.9⁸ = 0.430TD targetlesson 15.20G = 0.454-step returnlesson 15.23G = 0.33MC returnlesson 15.19G = 0.43
Toy: the 7-state random walk, γ 0.9, 100 walks, 20 runs × 10 episodes
STAGE 1 / 6
MATH · STAGE 1HOVER A SYMBOL OR A SHAPE
G0:n=R1+γR2+⋯+γn−1Rn+γn V(Sn)\sy{G}{out}{G_{0:n}} = \sy{R}{data}{R_1} + \gamma \sy{R}{data}{R_2} + \dots + \gamma^{n-1}\sy{R}{data}{R_n} + \gamma^{n}\,\sy{V}{out}{V(S_n)}
G0:4=0.94⋅V(C)=0.656⋅0.500=0.328G_{0:4} = 0.9^{4}\cdot V(C) = 0.656\cdot 0.500 = 0.328

Add n real rewards, then the guess V, scaled by γ to the n.

Common mix-ups

MYTHMonte Carlo has no bias, so it always learns best.

The fix, and 1 more mix-up with the diagram to show them, come with Pro.

Predict, then reveal
3 CHECKS · PRO
Q01If the guess is the true values, does the TD target still have bias?

Make your guess, then test it in the diagram. All 3 checks come with Pro.

PRO LESSON · YOU WATCHED STAGE 1 OF 6
Unlock the full explainer
  • 5 more stages and 3 live controls
  • 2 mix-up cards and 3 predict-then-reveal checks
  • Watch it as a narrated video, in three voices
  • Every Pro lesson and capstone · 656 in total

$99 a year, or $15 a month. Cancel any time.