Reinforcement Learning: An Introduction VI: Batch TD(0) Converges to the Certainty-Equivalence EstimateTextbook
Why batch TD(0) and batch Monte Carlo disagree
Temporal-difference (TD) learning estimates the value of each state of a Markov reward process from observed experience, updating an estimate toward a target built from the next reward and the current estimate of the next state. Monte Carlo (MC) methods instead update toward the full observed return. Both are standard prediction methods in reinforcement learning, and their relationship is a recurring question of the field (Sutton 1988).
When only a finite amount of experience is available, a common practice is to present the same data repeatedly until the estimates stop changing. Chapter 6 of Sutton and Barto's Reinforcement Learning: An Introduction (2nd ed., MIT Press, 2018) uses this setting to explain why TD(0) is often faster: under such batch updating, both methods converge deterministically, but to different answers. Batch MC finds the least-squares fit to the observed returns; batch TD(0) finds the value function of the maximum-likelihood Markov model of the data, the certainty-equivalence estimate. The comparison appears in §6.3, Optimality of TD(0) (pp. 126–128), and is illustrated by Example 6.4, You are the Predictor. The book states these conclusions without proof. This mission formalizes them.
Setting
Let be a finite set of nonterminal states and . An episode is a finite sequence with , real rewards , and terminal. A batch is a finite list of episodes. A visit of is an (episode, time ) pair with , and counts all visits (every-visit counting).
A value array is extended by . For a discount rate , the return is and the TD error is .
Batch TD(0) with step size computes the TD(0) increment for every visit in the batch and changes once, by their sum:
Batch constant- MC is the same iteration with the increment .
The maximum-likelihood model of the batch has transition probabilities , where counts the observed transitions from to , and expected rewards equal to the average reward observed on those transitions. With and , the certainty-equivalence estimate is the value function of this Markov reward process,
Formalization targets
Goal: batch TD(0) converges to the certainty-equivalence estimate
For every finite batch and every , the series defining converges, and there is such that for all and all initial arrays ,
The limit depends neither on nor on at visited states.
Milestones
- (6.6): with held fixed, .
- Exercise 6.8: the same identity for action values, .
- Least squares: the sample averages of the returns after the visits to minimize over all arrays .
- Batch MC: for small , batch constant- MC converges to at every visited .
- Fixed points: the batch TD(0) increments vanish everywhere if and only if on visited states.
- Example 6.4: on the eight episodes ; (six times); with , the certainty-equivalence estimate is and batch TD(0) converges to it, while batch MC converges to , .
Significance
The result explains the empirical observation of Figure 6.2 in the book: batch TD(0) has lower error than batch MC on Markov data, because it computes the certainty-equivalence estimate, while batch MC fits the training returns. It also gives a precise meaning to the claim that TD methods approximate the certainty-equivalence solution with memory linear in the number of states, where computing it directly needs a model of quadratic size and cubic time (p. 128). Identity (6.6) is the starting point of the -step and eligibility-trace methods of later chapters.
The comparison under repeated presentation of a finite training set goes back to Sutton 1988, but the textbook states the conclusions without proof, and no machine-checked version is known to exist. The formalization pins down every hypothesis the text leaves implicit: the step-size threshold, the treatment of unvisited states, every-visit counting, and the undiscounted case.
Difficulty
The fixed-point equation of batch TD(0) is on visited states, with the diagonal of visit counts, and convergence of the iteration requires every eigenvalue of to have positive real part. For this follows from being substochastic. For , the case of Example 6.4, is only substochastic and the naive contraction argument fails: invertibility of must be derived from the structure of the data, since every episode ends in the terminal state. The matrix is not symmetric, so symmetric positive-definiteness arguments do not apply. The same issue makes convergence of the series defining nontrivial at .
Formalization scope
An episode is a Lean List (X × ℝ) of transitions , with the terminal state represented by none : Option X; a batch is a list of episodes; states form a Fintype. Values at the terminal state are by definition. The certainty-equivalence estimate is defined from returns as the series , not as the solution of a Bellman equation, and its convergence is part of the goal, not assumed. "Sufficiently small " is an existential threshold quantified before and ; a statement for one fixed , or for some , would be weaker than the book's and is ruled out. Unvisited states receive no increment and keep their initial value; the goal records this rather than claiming convergence to there. The standing assumption includes . Every visit is counted in both the TD increments and the model; mixing first-visit and every-visit counts would make the goal false.
The mission needs only finite sums, matrix powers and limits of real sequences; Mathlib's Matrix and Filter.Tendsto suffice. A lemma that a nonnegative matrix whose rows reach an absorbing mass has spectral radius below one would be reusable beyond this mission, as would a convergence criterion for when is a nonsingular M-matrix. Contributions of either kind, and of the elementary milestones 1–3, are welcome.
Selected references
- Richard S. Sutton and Andrew G. Barto, Reinforcement Learning: An Introduction, 2nd ed., MIT Press, 2018, ISBN 9780262039246, §6.1 and §6.3, pp. 119–129. http://incompleteideas.net/book/the-book-2nd.html
- Richard S. Sutton, Learning to predict by the methods of temporal differences, Machine Learning 3, 9–44, 1988. https://doi.org/10.1007/BF00115009