TD vs Monte Carlo: Certainty Equivalence
What batch TD and batch Monte Carlo each converge to, and why TD often wins.
Eight episodes, two states, two answers. Batch Monte Carlo says state A is worth 0; batch TD says 0.75. Each is the best answer to a different question. This lesson proves what each method computes from a fixed batch of data, measures exactly how much TD gains by pooling evidence across states, constructs a problem where TD's answer stays wrong however much data arrives, and summarizes what theory says about the size of TD's advantage.
What you’ll learn
- Work through Sutton and Barto's "You are the predictor" example, and prove that batch TD(0) converges to the certainty-equivalence estimate while batch Monte Carlo fits the observed returns.
- Compute TD's variance advantage exactly in a two-state chain, and connect it to the plug-in principle of maximum likelihood.
- Construct an aliased problem in which TD's error does not vanish with data, and find the sample size at which Monte Carlo overtakes it.
- Summarize theoretical comparisons of TD and Monte Carlo: Kearns and Singh's bias–variance bounds and Cheikhi and Russo's characterization of TD's statistical benefit.
You are the predictor
Sutton and Barto (Example 6.4) ask you to play predictor. An unknown Markov reward process, with , produced eight episodes:
- one episode: A, reward 0, B, reward 0, end;
- six episodes: B, reward 1, end;
- one episode: B, reward 0, end.
Think first What are your best estimates of and ? Commit to numbers before revealing.
: B was seen eight times and was followed by a return of 1 six times. Everyone agrees on that. For there are two defensible answers. 0: the only return ever observed from A was 0. ¾: every time A occurred it moved to B with reward 0, and B is worth ¾. Batch Monte Carlo gives the first answer, batch TD(0) the second.
Let count the stored transitions out of each state. Summing the TD increments over the batch, one sweep is a linear iteration:
is substochastic (the missing mass is termination), so is a nonsingular M-matrix whenever every state in the data can reach termination under , which holds for data made of complete episodes. Multiplying by the positive diagonal keeps it one, so all eigenvalues of have positive real parts, and for small enough the iteration matrix has spectral radius below 1.
The iteration therefore converges, to the point where the summed TD errors vanish. Since is invertible on the visited states, that point solves the Bellman equation of the estimated model, independently of .
In the example, with , and B terminates with average reward . The model's values are and : batch TD's answer. Batch Monte Carlo minimizes the squared error on the training returns, which it does perfectly with . Fitting the past is one goal; predicting the future of a Markov process is another.
When certainty equivalence is right: pooling
If the process is Markov, the certainty-equivalence estimate is a plug-in estimate: is a smooth function of the model, and replacing the model by its maximum-likelihood estimate gives the maximum-likelihood estimate of . Such estimates are asymptotically efficient. The mechanism behind TD's advantage is that every transition out of a state informs the value of every state that leads to it. The smallest case can be computed exactly.
A moves to B with reward 0; B ends with reward 1 with probability and 0 otherwise. The data are episodes starting in A (each passing through B) and episodes starting in B. Batch Monte Carlo estimates from the returns observed after A:
Batch TD sets , and averages all outcomes observed after B. Both estimates are unbiased here, but TD's uses all the data:
The ratio is the fraction of B's data that Monte Carlo can use for A. In "You are the predictor" it is .
In this chain, 10 episodes start in A and 30 start in B. By what factor is batch Monte Carlo's mean squared error for larger than batch TD's?
Show the answer
4
. Monte Carlo uses only the 10 returns that followed A; TD uses all 40 observations of what follows B.
Cheikhi and Russo (2023) turned this intuition into a general asymptotic theory for finite Markov reward processes. They show that an inverse trajectory pooling coefficient completely characterizes the percentage reduction in mean squared error that TD achieves over direct (Monte Carlo) estimation: TD gains when trajectories from different starting states pass through common states, as A's and B's do here, and the reduction can be enormous or nonexistent depending on that structure. For estimating the difference between the values of two states, they bound TD's error by a trajectory crossing time, which can be much smaller than the horizon, so TD can be far more accurate at ranking states than at valuing them.
When certainty equivalence is wrong: aliasing
Certainty equivalence assumes the data come from a Markov process on the states you see. When the agent's states merge situations whose futures differ, the maximum-likelihood "Markov model" averages over the merged situations, and TD inherits that average. Here is the cleanest case, with numbers.
Two distinguishable doors, A and C, both lead (reward 0) to an observation X that hides which door was used. After door A, X ends with reward 1 with probability ; after door C, with probability ; . The data hold episodes through each door. Monte Carlo averages the returns after A, so it is unbiased:
TD's model has a single X, which ended with reward 1 in a fraction close to of episodes, and . That estimate is biased by , whatever is, but its variance is pooled over outcomes:
With and the comparison is against . TD has the smaller error while , and Monte Carlo afterwards:
So aliasing does not make TD useless: with little data its pooled, biased estimate can still be the more accurate one. But its error has a floor, here in absolute terms, while Monte Carlo's keeps shrinking. Multi-step returns sit in between: an -step or λ-return target for A includes more of the return that actually followed A, so it inherits less of X's averaged value and less bias, at the price of more variance.
That trade-off was made quantitative by Kearns and Singh (2000), who gave the first rigorous upper bounds on the error of TD methods for policy evaluation as a function of the amount of experience, for a phased version of -step TD and TD(). Their bounds converge exponentially fast to an asymptote, and both the rate and the asymptote depend strongly on or : longer backups pass on less of the current estimates' error per phase but add more variance from the sampled rewards. The bounds formalize the long-standing intuition of a bias–variance trade-off, and let them derive schedules for that change as learning proceeds.
Now and , with episodes through each door. From what number of episodes per door on is Monte Carlo's mean squared error for smaller than TD's?
Show the answer
3
Monte Carlo: . TD: bias , so . Monte Carlo wins when , that is , or ; with whole numbers of episodes, from on. A larger difference between the merged situations means a larger bias and an earlier crossover.
Choosing between them
| Situation | Favors | Reason |
|---|---|---|
| Markov states, little data per state | TD | certainty equivalence pools the evidence of every transition |
| Many start states whose trajectories share states | TD | large inverse pooling coefficient: shared futures are learned once |
| Merged or non-Markov states, plenty of data | Monte Carlo, or large | TD's aliasing bias does not shrink; Monte Carlo's variance does |
| Merged states, very little data | often still TD | a small bias can beat a large variance |
| Long horizons with noisy rewards | TD or intermediate | Monte Carlo's variance grows with the horizon |
| Function approximation | it depends | TD's fixed point can be worse than the best fit Monte Carlo finds, but TD often learns faster (Function Approximation & Deep Q-Learning) |
Key takeaways
- On a fixed batch, Monte Carlo converges to the sample means of the observed returns; TD(0) converges to the values of the maximum-likelihood Markov model (certainty equivalence), because its fixed point is the Bellman equation with and .
- On Markov problems certainty equivalence pools evidence: in the A→B chain, TD's mean squared error for is a fraction of Monte Carlo's; Cheikhi and Russo characterize the general gain by an inverse trajectory pooling coefficient.
- With aliased states TD's estimate is biased by the merged situations, and the bias does not shrink with data; Monte Carlo overtakes it once its variance falls below that bias (from in the 0.6/0.4 example).
- Multi-step returns trade TD's bias for Monte Carlo's variance; Kearns and Singh's bounds make that trade-off quantitative.
Check yourself
In the interactive lesson these are scored with your confidence, and what you miss comes back for review.
In "You are the predictor", what do batch Monte Carlo and batch TD(0) estimate for ?
- Monte Carlo , TD
- Both
- Both
- Monte Carlo , TD
Show the answer
D. Monte Carlo , TD
Monte Carlo averages the returns observed after A: one return, equal to 0. TD solves the estimated model's Bellman equation: A always went to B with reward 0, and , so .
What does "certainty equivalence" mean here?
- Estimating the model by maximum likelihood and then computing its values as if that model were certainly correct
- Using only the episodes whose returns are certain
- Requiring TD and Monte Carlo to agree before accepting an estimate
- Replacing random rewards by their certain upper bounds
Show the answer
A. Estimating the model by maximum likelihood and then computing its values as if that model were certainly correct
The term comes from control theory: plug the estimated parameters into the optimal rule as if they were the true ones, ignoring the uncertainty in them. Batch TD(0) computes the certainty-equivalence values without ever storing the estimated model.
In the aliased example with and , what happens to batch TD's error for as the number of episodes grows without bound?
- It tends to 0, like Monte Carlo's
- It grows, because errors propagate
- It tends to an absolute error of 0.1: TD converges to instead of 0.6
- It oscillates forever between 0.4 and 0.6
Show the answer
C. It tends to an absolute error of 0.1: TD converges to instead of 0.6
The variance term vanishes, but the bias does not: the merged state is valued at the average of the two situations it hides, and A inherits that value. Monte Carlo's error goes to 0, which is why it overtakes TD from about 12 episodes per door.
What did Kearns and Singh's (2000) bounds for phased -step TD and TD() formalize?
- That TD always beats Monte Carlo
- A bias–variance trade-off: the rate at which errors shrink across phases, and the level they settle at, both depend on or , with longer backups trading bias for variance
- That TD() diverges for close to 1
- That certainty equivalence is the minimum-variance unbiased estimator
Show the answer
B. A bias–variance trade-off: the rate at which errors shrink across phases, and the level they settle at, both depend on or , with longer backups trading bias for variance
Their upper bounds converge exponentially fast to an asymptote, with the rate and the asymptote depending strongly on the backup length. Short backups lean on current estimates (bias); long ones sum more sampled rewards (variance). The bounds turn the intuition into numbers and suggest schedules for .
Further reading
- R. S. Sutton, "Learning to predict by the methods of temporal differences," Machine Learning 3, 9–44 (1988).
- R. S. Sutton & A. G. Barto, Reinforcement Learning: An Introduction, §6.3 (MIT Press, 2nd ed., 2018).
- M. Kearns & S. Singh, "Bias-variance error bounds for temporal difference updates," Proceedings of the 13th Annual Conference on Computational Learning Theory (COLT), 142–147 (2000).
- D. Cheikhi & D. Russo, "On the statistical benefits of temporal difference learning," Proceedings of the 40th International Conference on Machine Learning (ICML), PMLR 202, 4269–4293 (2023).