Without a model you cannot compute dynamic programming's expectation over next states, so you replace it with a sample: the whole return (Monte Carlo), or one real reward plus your own estimate of where you landed (TD). Every method on this page is one choice of that target: how many real rewards before it trusts an estimate (a bias-variance dial), and which next action it assumes (the one taken: on-policy; the best one: off-policy).
Two choices define every target: how far it looks, and which next action it trusts
You need: the Bellman expectation backup and policy evaluation from Dynamic programming (this page samples its backups), and the loop, return and value vocabulary of Topic: rl (its Method atlas tab dates every method here). ε-greedy and other exploration rules are on Bandits and exploration.
| Method | The target (what stands in for the expectation) | Bias and variance | Whose values |
|---|---|---|---|
| Monte Carlo | The whole sampled return Gt to the end of the episode | Unbiased; high variance; needs episodes that end | The policy that generated the data (another one, with importance sampling) |
| TD(0) | One real reward plus the current estimate, R + γV(S′) | Biased by the estimate; low variance; one step of experience | The policy that generated the data |
| n-step TD, TD(λ) | n real rewards, then the estimate; or a geometric blend of all n | A dial between the two above (n steps, or eligibility traces) | The policy that generated the data |
| SARSA | R + γQ(S′, A′), A′ the action actually taken next | As TD(0) | On-policy: the exploring policy it runs |
| Expected SARSA | R + γ Σa π(a | S′) Q(S′, a) | Removes the variance of the next action | Either; with a greedy π it is Q-learning |
| Q-learning | R + γ maxa Q(S′, a) | As TD(0), plus an upward maximisation bias | Off-policy: the greedy policy, whatever the agent does |
| Double Q-learning | R + γQ2(S′, argmaxa Q1(S′, a)) | Removes the maximisation bias; two tables | Off-policy, greedy |
| Off-policy Monte Carlo | The return reweighted by the importance ratio ρ | Ordinary: unbiased, variance can be infinite; weighted: biased, low variance | Any target policy π covered by the behaviour b |
Rows jump to their section. The modern targets are these ones: DQN regresses a network onto the Q-learning target, PPO's critic learns a TD target and its advantage is a TD(λ) average, and GRPO's end-of-sequence reward is a Monte Carlo return (section 8). Every chart below reruns a figure of Sutton and Barto's book live and seeded; numbers are published with the source linked, unless marked derived (computed here, formula shown) or illustrative.
The test problem is the five-state random walk (Sutton and Barto, Example 6.2): states A to E in a row, every episode starts in C and steps left or right with probability 0.5 until it falls off an end; falling off the right pays 1, every other reward is 0, γ = 1. So the true value of a state is its chance of ending on the right, Vπ = (1/6, 2/6, 3/6, 4/6, 5/6). Estimates start at 0.5; α = 0.1. One episode: C → D → E → off the right end, rewards 0, 0, 1.
TD(0) updates after every step
Monte Carlo waits for the end
Every visited state had return G = 1, so V(C), V(D) and V(E) each become 0.5 + 0.1 × (1 − 0.5) = 0.55.
MC moved three states by the full surprise; TD moved one. TD's information travels back one state per episode (next time the walk passes D → E, D's target is 0 + 0.55 and D rises to 0.505), but each TD target carries one step of randomness, while each MC credit carries the whole walk's luck. As updates:
TD is DP's policy-evaluation backup, V(s) ← Eπ[R + γV(S′) | s], with the expectation replaced by one sample and a step of size α towards it: it "updates a guess towards a guess" (Silver, Lecture 4).
Predict, then play: over 100 walks, does any Monte Carlo step size end below the worst TD one?
The replay beside this opens after 10 walks, a point of the book's left graph; Play runs the rest a move at a time.
Bars: estimates; dashed: true values. Every TD curve stays below every MC curve; TD with α = 0.15 bottoms out and rises again (Exercise 6.5): a large constant step keeps reacting to the latest walks. The starting error is √(1/18) = 0.236. Batch mode replays all episodes so far to convergence: batch Monte Carlo gives each state the mean return seen after it, batch TD the values of the Markov chain estimated from the transitions (certainty equivalence, p. 128).
Batch updating, computed exactly: sample means for Monte Carlo, the estimated chain solved by Gaussian elimination for TD. check.py replays batches with α = 0.001 and lands on the same values to 5 × 10−10.
Example 6.2 (right graph) and Figure 6.2 reproduce in shape: the book gives its curves only as images, so values are not read off them. After one episode both batch methods give 0.412, above the top of the book's axis (0.25), so the book's plot must be cut off there; it does not say.
| Monte Carlo | TD | |
|---|---|---|
| Target | Actual return Gt | R + γV(S′), bootstrapped |
| Bias / variance | Unbiased / high: Gt carries every random action, transition and reward to the end | Biased (the estimate may be wrong) / low: one step of randomness |
| When it learns | At the end of an episode; episodic tasks only | After every step; continuing tasks too |
| Initial values | Matter little | Matter more |
| Markov property | Not used: better when the state is partly observed | Exploited: usually more sample-efficient when it holds |
| On a fixed batch | Least-squares fit to the observed returns | Exact values of the maximum-likelihood Markov model |
| Tabular convergence | To Vπ, by the law of large numbers | To Vπ: in the mean for a small constant α (Sutton 1988), with probability 1 for decreasing step sizes (Σα = ∞, Σα2 < ∞; Dayan 1992) |
| With function approximation | Converges (to a local optimum with a non-linear approximator) | Linear and on-policy: converges to the TD fixed point; otherwise can diverge (section 7) |
Batch MC and batch TD converge to different answers on the same data (Example 6.4). Eight episodes: A, 0, B, 0 once; B, 1 six times; B, 0 once. Both give V(B) = 6/8 = 0.75. Batch MC gives V(A) = 0, the only return seen from A; batch TD gives V(A) = 0.75, because A always led to B. TD's answer is the value under the maximum-likelihood Markov model of the data (certainty equivalence), which predicts future data better if the process is Markov (the optimality of batch TD(0) is from Sutton 1988); that is why batch TD beats batch MC on the walk (switch the chart to Batch). Silver's version: you nearly crash and the episode ends fine; MC credits every state with the good ending, TD marks down the states before the moment the crash looked certain.
First-visit MC uses only the first visit to a state in each episode; every-visit MC uses all of them. First-visit returns are independent, identically distributed samples of Vπ(s), so each average is unbiased and its standard error falls as 1/√n; every-visit returns from one episode are correlated and its estimate is biased for a finite number of episodes, but it also converges and "extends more naturally to function approximation and eligibility traces" (Sutton and Barto, §5.1; Singh and Sutton 1996 compare the two and tie first-visit MC to replacing traces, every-visit to accumulating ones). The incremental form follows from μk = μk−1 + (1/k)(xk − μk−1).
Because MC does not bootstrap, the cost of estimating one state does not depend on the number of states: generate episodes from the states you care about and ignore the rest (§5.1). Model-free methods also apply when a model exists but is only usable by sampling (Go, Silver, Lecture 5), or when its probabilities are hard to write down: blackjack's rules are fully known, yet "it is not easy to determine" each outcome's probability for DP, while sample games are easy (§5.1). The price is the exploration problem of section 3: you learn only about states you visit. DP's full-width backups touch every successor; model-free sample backups cost the same whatever the number of states.
History: "Monte Carlo" dates from the 1940s at Los Alamos; an early RL use was Michie and Chambers (1968), who averaged episode durations in pole balancing, "similar in spirit to Monte Carlo ES with every-visit MC estimates"; Monte Carlo ES first appeared in the 1998 edition of the book (chapter 5 notes).
Between one step and the whole episode lie the n-step returns: take n real rewards, then bootstrap (Sutton and Barto, §7.1). TD(λ) averages all of them with geometrically decaying weights, the λ-return (forward view from Watkins 1989; TD(λ) itself from Sutton 1988). On the walk episode above, from C with all values 0.5: G(1) = 0 + V(D) = 0.5, G(2) = 0 + 0 + V(E) = 0.5, G(3) = G = 1. With λ = 0.5 the weights are 0.5, 0.25 and the remaining 0.25, so Gλ = 0.625, between TD's 0.5 and MC's 1. Move λ:
The λ-return is a forward view: like MC, it needs the rest of the episode. The backward view gets nearly the same update online with an eligibility trace per state that records how recently and how often it was visited, and broadcasts each one-step TD error back in proportion (§12.2):
Predict: on the 19-state walk, which n gives the lowest error at its best step size, 1, 4 or 512 (Monte Carlo)?
In deep RL the same dial is generalised advantage estimation (GAE; Schulman et al. 2015), Ât = Σl≥0 (γλ)l δt+l, the advantage of actor-critic methods, worked through on Policy gradients and actor-critic.
Error-reduction property: the worst error of the expected n-step return is at most γn times the worst error of V (§7.1, equation 7.3), so each extra real reward shrinks the bias the estimate can pass on. n-step TD updates V(St) only n steps later.
Traces. The accumulating trace adds 1 on every visit. The replacing trace resets it to 1, so a state revisited in a loop never builds a trace above 1 (Singh and Sutton 1996). The dutch trace makes the online backward view exactly equal to the online λ-return with linear approximation: true online TD(λ) (van Seijen and Sutton 2014; §12.5). Sutton and Barto now see replacing traces as "crude approximations to dutch traces, which largely supersede them" (§12.6).
The replay beside this opens on the walk's last step: n-step TD updates only the state n steps back, while TD(λ) shares the final TD error out along the traces.
The 19-state walk of Example 7.1: −1 off the left, +1 off the right, values start at 0 (true values −0.9 to 0.9), α = 0.4 in the replay. The bracket shows which estimate an n-step update borrows; the bars under TD(λ) are the traces.
An intermediate setting is best: n = 4 or λ = 0.8 in this rerun, with error rising toward both ends; the more an update relies on actual returns, the smaller the step size it tolerates. The axis stops at 0.55 as the book's does; every curve starts at √0.3 = 0.548. Online TD(λ) only approximates the λ-return: close below the best α, apart above it, and it diverges for λ ≥ 0.9 (Figure 12.6). Tap a legend entry to hide a curve.
Figures 7.2 and 12.3 reproduce in shape (the off-line λ-return slightly beats n-step TD at the best setting, 0.277 against 0.278, and at high α, as the caption says). Figure 12.6 reproduces partly: TD(λ) is worse at high α and diverges for λ ≥ 0.9, but below the best α the book calls the two "virtually identical", and here they are close (within 0.031), not identical, because the online updates differ even at λ = 0.
Control runs DP's loop, evaluate then improve (generalised policy iteration, §5.3; taught on Dynamic programming), and sampling breaks both halves. Improvement greedy on V needs the model, π′(s) = argmaxa [R(s, a) + γ Σs′ P(s′ | s, a) V(s′)], so model-free control learns Q(s, a), where greedy is a plain argmax. And evaluation only covers what the agent visits, so a greedy policy can lock onto a wrong action it never retries: the policy must keep exploring.
ε-greedy: with probability 1 − ε the greedy action, otherwise one of the m actions uniformly, so the greedy action has probability 1 − ε + ε/m and every other ε/m. The ε-greedy policy with respect to Qπ is at least as good as any ε-soft π (every action at least ε/m), because its value puts the 1 − ε mass on the largest Q (§5.4, equation 5.2). The catch: improvement then finds only the best ε-soft policy. For the optimum, exploration must fade: a schedule is GLIE (greedy in the limit with infinite exploration) when every pair is visited infinitely often and the policy converges to greedy; εk = 1/k on the k-th episode is GLIE (Silver, Lecture 5).
Monte Carlo ES starts every episode from a random state-action pair, every pair possible, so all pairs are visited however greedy the policy is; after each episode it averages the returns that followed each first visit into Q and makes the policy greedy at the visited states (§5.3, box). On blackjack it finds a policy matching Thorp's (1966) basic strategy except one notch in the usable-ace policy, which the authors are "confident" is optimal for their version (Example 5.3, Figure 5.2). It cannot settle on a suboptimal policy, but "convergence to this optimal fixed point ... has not yet been formally proved", "one of the most fundamental open theoretical questions in reinforcement learning" (partial solution: Tsitsiklis 2002). Exploring starts are easy in a simulator and rarely possible with real interaction.
GLIE Monte Carlo control: sample the k-th episode with the ε-greedy policy; for each visited pair increment N(St, At) and move Q(St, At) by (1/N)(Gt − Q); set ε ← 1/k. It converges to Q* (Silver, Lecture 5).
Put TD in the control loop: update Q after every step, act ε-greedily on the latest Q. One transition shows the whole difference. illustrative The agent is in S beside a cliff, took A = right, got R = −1; γ = 1, α = 0.5, Q(S, right) = −5. In S′, Q(S′, right) = −4 is best and Q(S′, down) = −100 steps into the cliff; exploration happened to pick A′ = down.
SARSA's value of "right, beside the cliff" absorbs the risk that its own exploration stumbles in; Q-learning's assumes greedy behaviour from S′ on. Change the numbers (the two other actions in S′ are −5 and −6, for Expected SARSA's average):
SARSA learns the value of the policy it runs, exploration included: on-policy TD control. Q-learning (Watkins 1989; proof Watkins and Dayan 1992) behaves ε-greedily (the behaviour policy) but its target evaluates the greedy policy (the target policy): off-policy, and needing no importance ratio, because the target never uses the action the behaviour chose next; behaviour only decides which pairs get updated. That is what lets DQN learn from a replay buffer. Its max is the Bellman optimality backup, so it is sampled value iteration. Expected SARSA removes the variance of the random A′ and, with a greedy target policy, is exactly Q-learning (§6.6).
Predict: in the episode beside this list, which learner's value for the step just before the fall changes most?
One recorded episode, four learners: only the target differs
A 3 × 6 cliff (start S bottom left, goal G bottom right, four cliff cells between; −1 per move, −100 and back to the start for a fall). illustrative setup, exact arithmetic: the starting table is Q-learning's after 30 seeded episodes (α = 0.5, ε = 0.1); the episode is ε-greedy on that table, held fixed so all four see the same moves; α = 0.5, ε = 0.1, γ = 1; Monte Carlo is every-visit constant-α. Checked against src/checks/recompute.py.
Cliff walking (Example 6.6; Gymnasium, Cliff Walking) turns this into reward. A 4 by 12 grid, start bottom left, goal bottom right, the ten cells between them the cliff: −1 per step, −100 and back to the start for a fall, undiscounted, ε = 0.1. The optimal path hugs the edge: up 1, right 11, down 1, 13 steps, return −13, and Q-learning learns its values. But on each of the ten edge cells the random 10% of actions picks "down" a quarter of the time, 0.1/4 = 0.025 per step, so a pass survives with probability 0.97510 ≈ 0.776 and about 22% of passes fall at least once derived. SARSA learns a longer path through the upper part of the grid, because its values include its own stumbles, and so earns more while ε stays at 0.1.
Which is "right" depends on the question. Q-learning answers "what is optimal if I stop exploring?"; SARSA "what is best given that I keep exploring like this?". For a robot exploring on real hardware, SARSA's answer is the safer one; Q-learning's values are not the return you will get while exploration continues (−50.8 expected, against −13 for the greedy path).
SARSA converges to Q* with probability 1 under GLIE policies and Robbins-Monro step sizes, Σt αt = ∞ and Σt αt2 < ∞: big enough in total to overcome any initial values, shrinking fast enough for the noise to average out (§6.4; proof Singh, Jaakkola, Littman and Szepesvári 2000). Those conditions are for proofs: they "are seldom used in applications and empirical research", where a constant α is the norm and never fully settles but tracks change (§2.5). With ε fixed, SARSA settles on the best policy given that it keeps exploring.
Q-learning needs only that every pair keeps being updated, plus "a variant of the usual stochastic approximation conditions" on the step sizes (§6.5; general proofs Jaakkola, Jordan and Singh 1994, Tsitsiklis 1994); ε need not decay for the values to converge, only for the behaviour to become optimal.
Expected SARSA on the deterministic cliff "can safely set α = 1 without suffering any degradation of asymptotic performance, whereas Sarsa can only perform well in the long run at a small value of α" (Figure 6.3, from van Seijen, van Hasselt, Whiteson and Wiering 2009); it "subsumes and generalizes Q-learning while reliably improving over Sarsa", at a small extra cost per step.
n-step SARSA targets Rt+1 + ... + γn−1Rt+n + γnQ(St+n, At+n) (§7.2); SARSA(λ) keeps one trace per state-action pair (§12.7). On a gridworld with one reward at the goal, an episode of one-step SARSA strengthens only the last action before the goal, n-step SARSA the last n (Figure 7.4). Expected SARSA goes back to George John (1994).
History: SARSA came after Q-learning. Rummery and Niranjan introduced it in 1994 as "Modified Connectionist Q-learning"; the name "Sarsa" is from Sutton (1996) (chapter 6 notes).
The cliff replay beside this opens on the tables after the last of 500 episodes; Play replays the run from the start.
Shading: the best Q-value in each cell (darker is worse); arrows: the greedy move; trail: this episode, falls crossed. Over episodes 401 to 500 (100 runs; the book does not state α, 0.5 is assumed): SARSA −27.4 per episode, Q-learning −50.3, and Expected SARSA −20.8 if you pick it. Acting ε-greedily around the edge path is worth exactly −50.80 per episode (policy evaluation on the known grid), which is where Q-learning's average settles. The axis is cut at −100 as the book's is, so early episodes (several hundred) leave the bottom. With ε decaying, both would converge to the edge path.
A max over noisy estimates is biased upwards. If 10 actions are all truly worth 0 and each estimate carries unit noise, the expected largest estimate is 1.539 derived: whichever got lucky wins. Q-learning's target is that max, and an ε-greedy SARSA uses it through the greedy part of its policy; the optimism flows back into every state that leads there (§6.7). The cause is using the same samples to pick the action and to value it. Double learning keeps two independent estimates and values one's choice with the other, Q2(argmaxa Q1(a)), whose expectation is the true value of the chosen action.
Example 6.7 makes the bias cost reward. From A, right ends with reward 0; left goes to B, whose actions all end with a reward drawn from a normal with mean −0.1 and variance 1. Left is always a mistake, yet Q-learning "initially learns to take the left action much more often than the right action", while Double Q-learning "is essentially unaffected". Both act ε-greedily with ε = 0.1, α = 0.1, estimates starting at 0; the book says only that B has "many possible actions", so 10 are assumed here, as in Zhang's reproduction.
Double DQN is the same idea with the two networks DQN already has (van Hasselt, Guez and Silver 2015; on Value-based deep RL).
The replay beside this opens after episode 100 of one seeded run; compare how often each learner has gone left (under each panel).
Dots: the estimates of B's actions (Double Q-learning: the average of its two tables); Q-learning's target for "left" is the highest dot. Bars: the two estimates in A.
The dashed 5% is the best an ε-greedy agent can do: a random action 10% of the time, half of them left. 10,000 runs, as the book.
Figure 6.5 reproduces in shape: every statement of the caption and text holds live. The peak height depends on the number of actions in B, which the book does not state. The curves exist only as an image, so values are not compared.
Off-policy learning learns about a target policy π from data of a behaviour policy b: from demonstrations or other agents, from old policies' data, a greedy target while behaving exploratorily, several policies from one stream (Silver, Lecture 5). It needs coverage: every action π might take has non-zero probability under b (§5.5). Q-learning gets away without a correction; a Monte Carlo return does not, because the whole rest of the episode followed b's choices. The correction weights each return by how much more likely π was to produce it; the transition probabilities appear in both policies' trajectory probabilities and cancel. Concretely: if b took an action with probability 0.25 that π takes with probability 0.5, the sample counts double (ρ = 2); an action π never takes gives weight 0 to the whole return from before it.
Predict: on one blackjack state learned from random play, which estimator is closer to the truth after 10 episodes?
The replay beside this opens on all 200 episodes of one run; scrub to episode 10 to check your prediction.
Example 5.4 (p. 106): the dealer shows a 2, the player holds 13 with a usable ace. π sticks only on 20 or 21; b hits or sticks with probability ½ each, so ρ doubles for every decision that matches π and drops to 0 at the first that does not. Infinite deck, dealer hits below 17; win +1, draw 0, loss −1 (Example 5.1).
The state's value, −0.27726 in the book from 100 million simulated games, is −0.27720 computed exactly here by recursion over the infinite deck derived, within the book's sampling error (about 0.0001): an independent reproduction. Each run starts from an estimate of 0; the axis stops at 5 as the book's does.
Figure 5.3 reproduces in shape; values are not read off the image.
When π loops, ordinary importance sampling can have infinite variance (Example 5.5). One state; right ends with reward 0; left returns to the state with probability 0.9 or ends with +1 with probability 0.1. π always goes left, so vπ = 1; b goes either way with probability ½. An episode with k lefts has ρ = 2k and G = 1, so every scaled return has expectation 1, but E[(ρG)2] = Σk≥1 (½)k 0.9k−1 0.1 · 4k = 0.2 Σj≥0 1.8j = ∞: rare long all-left episodes carry enormous weights.
The same ratio, clipped, is the heart of PPO and GRPO: their rollouts come from a slightly stale copy of the policy and from an inference engine whose probabilities differ slightly from the trainer's, so language-model RL is mildly off-policy and corrects per token (RL for LLMs; Policy gradients and actor-critic).
Weighted importance sampling (dashed) is exactly 1 from the first episode consistent with π, because only those returns get any weight, and all are 1. The book runs to 100 million episodes; 10 million is the most offered here, for a phone.
Every method so far stores one number per state or state-action pair and learns nothing about a state it has not visited, which fails as soon as the state space is large or continuous. Replace the table with v̂(s, w) and move the weights along the gradient of the estimate, treating the target as fixed: semi-gradient TD(0), w ← w + α [R + γv̂(S′, w) − v̂(S, w)] ∇v̂(S, w) (§9.3). Monte Carlo with the same update is true gradient descent on squared error; TD is not, because its target moves with w. With linear features and on-policy data it still converges, to the TD fixed point, whose error is at most 1/(1 − γ) times the best the features allow (§9.4, equation 9.14): a factor of 100 at γ = 0.99 derived.
The failure has a name. The deadly triad is function approximation (generalising across states), bootstrapping (targets built from current estimates, as in TD and DP) and off-policy training (updates on a distribution other than the target policy's): "If any two elements of the deadly triad are present, but not all three, then instability can be avoided" (§11.3). It needs neither control nor sampling: it appears in prediction, even with DP's expected updates. The smallest case is two states whose estimates share one weight, w and 2w, with a transition from the first to the second paying 0 (§11.2): the TD error is γ · 2w − w = (2γ − 1)w, so each update multiplies w by 1 + α(2γ − 1), above 1 whenever γ > 0.5. With α = 0.1 and γ = 1, w goes 10, 11, 12.1 derived: raising the first state raises the second twice as much. On-policy, the 2w state's own update would pull w back; off-policy, nothing does. With the on-policy distribution of updates, convergence is guaranteed (§11.2).
Baird's counterexample is the complete version (Baird 1995; Figure 11.1). Seven states, eight weights: the six upper states have value 2wi + w8, the seventh w7 + 2w8; every reward is 0, so every true value is 0, which w = 0 represents exactly. The target policy always takes the "solid" action to state 7; the behaviour policy takes "dashed" (to a random upper state) with probability 6/7, so all seven states are updated equally often. With γ = 0.99 the weights diverge "for any positive step size, no matter how small", even with expected updates of every state at once.
Predict: which single switch below stops the weights from growing? Then flip each one.
Q-learning with a network and a replay buffer has all three legs, which is why DQN needed target networks and replay, and why Double DQN and multi-step targets help: that story, the measured "soft divergence" of DQN variants on Atari and the gradient-TD fixes are on Value-based deep RL.
Expected (DP-style) semi-gradient updates, one sweep over the states being updated, α = 0.01, γ = 0.99, w0 = (1, 1, 1, 1, 1, 1, 10, 1): the setting of Figure 11.2 (right). With all three legs, after 1,000 sweeps w8 reaches 335, w1 to w6 114 and w7 6.85 derived, the book's shape (it prints only curves). "A table" gives each state its own weight, starting at the same values (3 and 12); "Monte Carlo" uses the true return under the target policy, 0. The bounded cases shrink slowly because each target keeps 99% of an estimate. Checked against src/checks/recompute.py.
Each TD control method samples a DP method on Q, with x ←α y meaning x ← x + α(y − x) (Silver, Lecture 5). His "unified view" adds the other two corners: full-width to the end of the episode is exhaustive search, sampled to the end is Monte Carlo; Expected SARSA sits between the columns, sampling the next state but not the next action.
| Bellman equation | Full backup (DP, needs the model) | Sample backup (TD, model-free) |
|---|---|---|
| Expectation, V | Iterative policy evaluation: V(s) ← E[R + γV(S′) | s] | TD learning: V(S) ←α R + γV(S′) |
| Expectation, Q | Q-policy iteration: Q(s, a) ← E[R + γQ(S′, A′) | s, a] | SARSA: Q(S, A) ←α R + γQ(S′, A′) |
| Optimality, Q | Q-value iteration: Q(s, a) ← E[R + γ maxa′ Q(S′, a′) | s, a] | Q-learning: Q(S, A) ←α R + γ maxa′ Q(S′, a′) |
| Choice | Pick | Because |
|---|---|---|
| Prediction, continuing task or long episodes, state close to Markov | TD, or an intermediate n or λ | Learns mid-episode, lower variance; the middle of the dial usually beats both ends |
| Prediction, short episodes, state partly observed | Monte Carlo or a large λ | Does not rely on the Markov property; more robust with function approximation |
| Control, reward while learning matters (real hardware) | SARSA or Expected SARSA | Optimises the exploring policy it actually runs |
| Control in a simulator, or from old or someone else's data | Q-learning (Expected SARSA with a greedy target) | Learns the greedy optimum; one-step off-policy needs no ratio |
| Noisy rewards, many competing actions | Double Q-learning (Double DQN with networks) | Removes maximisation bias |
| Off-policy Monte Carlo | Weighted importance sampling | Bounded variance; expect slow learning when π and b often disagree |
| Step size α, exploration ε | Constant α; decay ε (GLIE) when the final policy should be greedy | Larger α learns faster and fluctuates more, and tracks a changing problem; more ε finds better actions and costs reward while learning |
Where it goes next. Replace the table with a network, plus a replay buffer (legitimate because Q-learning is off-policy) and a frozen target network: Value-based deep RL, where Double DQN is the double-learning fix and n-step targets return in Rainbow. Actor-critic methods learn a critic with TD targets and use GAE as the dial (Policy gradients and actor-critic). Dyna mixes Q-learning on real experience with Q-learning on experience simulated from a learned model (Model-based RL and planning). Learning from a fixed dataset with no interaction is offline RL, a different problem from off-policy learning (Offline RL and imitation). In language-model RL (RL for LLMs: RLHF, GRPO, RLVR), GRPO's single end-of-sequence reward against a group mean is a Monte Carlo return (unbiased, no value model, high variance), and PPO with a value model sits partway along the TD(λ) dial through GAE, its λ choosing the trade-off. On Topic: rl's axes all four methods are model-free and value-based; SARSA is on-policy and Q-learning off-policy; Monte Carlo does not bootstrap and TD does.
src/lab/check.py ports the engine of the random-walk, 19-state and cliff experiments line by line and reproduces their numbers bit for bit; it also checks independently: true values by linear solve, the batch closed forms against replayed batches, the λ-return recursion against equation 12.3, the cases where methods coincide (n = 1 and λ = 0 are TD(0); n ≥ episode length and λ = 1 are Monte Carlo), and the cliff's exact ε-greedy returns by linear solve. src/checks/recompute.py does the same for the maximisation-bias, importance-sampling and Baird experiments and the four-learner animation.Sources: Sutton and Barto, Reinforcement Learning: An Introduction (2nd ed., 2018), chapters 5 to 7, 9, 11 and 12; David Silver's UCL Lectures 4 and 5; the primary papers linked in each paragraph. Further reading, with times, is in the last tab.
Links open in a new tab, with reading times. Times for knowledge base pages are their own; times for papers are estimates for a careful first read of the main text.
Section 1: Example 6.2 and Figure 6.2, the same random walks through TD(0) and Monte Carlo, online and batch.
Section 2: Figures 7.2, 12.3 and 12.6 on the 19-state walk, with one episode through n-step TD and TD(λ) side by side.
Section 4: Example 6.6, SARSA, Q-learning and Expected SARSA, with the exact ε-greedy return of the edge path.
Section 5: Figure 6.5, Q-learning against Double Q-learning over 10,000 runs, and one run stepped.
Section 6: Figures 5.3 and 5.4, ordinary against weighted importance sampling, and a case of infinite variance.
Section 7: Baird's counterexample (Figure 11.2) with each leg of the triad switched off in turn.
The overview this page belongs to: the loop, the Bellman equation and "one target, many estimators", with the Taxonomy, Method atlas (each method's first paper and year) and Milestones and benchmarks tabs. (17 min, plus 2 in closed details)
The page before this one in reading order: ε-greedy, optimistic starts, UCB, Thompson sampling and regret, with no states. (27 min, plus 9 in closed details)
The full-width backups this page samples: policy evaluation, policy and value iteration, and Figure 4.1's gridworld solved by model and by samples. (39 min, plus 11 in closed details · +7h 15m resources)
The next page: Q-learning with a network, how DQN tames the deadly triad (replay and target networks, soft divergence on Atari), Double DQN, dueling, Rainbow. (29 min, plus 16 in closed details)
Where TD targets become critics and the λ-dial becomes GAE; REINFORCE as the Monte Carlo end. (45 min, plus 9 in closed details)
Dyna's mix of Q-learning on real and simulated experience, tree search, learned models. (41 min, plus 9 in closed details)
Off-policy learning taken to its limit: a fixed dataset, no interaction, and what the max in a Q-learning target does there. (34 min, plus 9 in closed details)
GRPO as the Monte Carlo end of the dial, PPO's GAE critic, and the importance ratios of mildly off-policy rollouts. (53 min, plus 13 in closed details · +20h 55m resources)
The paper page that introduced GRPO, with PPO against GRPO animated. (25 min read)
"Model-Free Prediction" and "Model-Free Control"; the near-crash analogy for MC against TD is from Lecture 4. Slides: Lecture 4, Lecture 5. (3h)
Monte Carlo methods, TD learning, n-step bootstrapping: every chart on this page reruns one of their figures. (2h 15m)
Eligibility traces in depth: the λ-return, TD(λ), true online TD(λ) and dutch traces, SARSA(λ), Watkins's Q(λ) and tree backup. (about 1h 30m, estimated)
The sections on MC, TD, SARSA and Q-learning: compact equations for everything here. (about 15 min)
Watch TD learn without a model, with eligibility traces you can switch on. (about 10 min)
Short scripts for the random walks, cliff walking, maximisation bias and the blackjack examples; useful to compare with this page's own implementation. (about 30 min)
First-visit against every-visit Monte Carlo, and replacing against accumulating traces. (about 1h)
TD learning, TD(λ) and the random walk. (about 1h)
Convergence of tabular TD with probability 1. (about 45 min)
The online backward view made exactly equal to the forward view, with dutch traces. (about 45 min)
The partial answer to whether Monte Carlo ES converges. (about 45 min)
"Convergence results for single-step on-policy reinforcement-learning algorithms": SARSA under GLIE. (about 1h)
"A theoretical and empirical analysis of Expected Sarsa", the source of Figure 6.3. (about 30 min)
Q-learning and the λ-return; then the convergence proof. (about 40 min for the 1992 paper)
Maximisation bias and the double estimator. (about 30 min)
Retrace: multi-step off-policy returns with truncated importance ratios. (about 1h)
The seven-state counterexample of section 7. (about 40 min)
Semi-gradient methods and the TD fixed point; off-policy divergence, Baird's counterexample and the deadly triad. (about 2h, estimated)