Martingales, Markov Chains and Brownian Motion
What can be proved about randomness that unfolds in time?
In 1913 Markov counts the vowels and consonants in the first 20,000 letters of Pushkin's Eugene Onegin to answer Nekrasov, who had claimed that the law of large numbers needs independence: a vowel follows a vowel with probability 0.128, a consonant with 0.663, and the long-run share still settles. The part builds the theory of dependence in time. Conditional expectation is defined by Radon-Nikodym and as a projection, and martingales follow with Doob's theorems: optional stopping (gambler's ruin, and why doubling fails), the maximal inequalities, and convergence by upcrossings. Ville's inequality is drawn with the betting paths: a likelihood-ratio wealth under the null reaches 10 with probability at most a tenth, however often one looks. Concentration and the martingale CLT justify the AR(1) interval; drift and minorization give the CLT behind MCMC standard errors, and coupling bounds mixing times on the cycle, the hypercube and a deck of cards. The part then constructs Brownian motion by Levy and Ciesielski, proves Donsker's principle and explains the Dickey-Fuller law, and ends with the iterated logarithm and the martingales under survival analysis.
What you need. Part 43's measure theory (sigma-algebras, the integral and its convergence theorems, weak convergence), and linear algebra for the eigenvalues of a transition matrix.
- Hook
- Markov vs Nekrasov, 1913
- Mathematics
- conditional expectation (Radon–Nikodym), Doob's theorems, uniform integrability, reverse martingales, martingale CLT, Harris chains and drift conditions, coupling, Brownian motion, Donsker, LIL, counting processes
- Built
- a coupling and mixing lab
What you will be able to do
Bachelor's
- Explain what Markov's count of Onegin showed about dependence and the law of large numbers.
- Compute the chance of doubling a stake and the expected length of play in a fair game, and say why no stopping rule makes a fair game favourable.
Master's
- Compute gambler's ruin probabilities for an unfair game with de Moivre's martingale.
- Compute a finite chain's distance from stationarity, its mixing time and its relaxation time, and bound the first by a coupling.
PhD
- Prove optional stopping under each of its three conditions and give the doubling strategy as the counterexample when they fail.
- Prove Ville's inequality from Doob's maximal inequality, and almost-sure convergence of L1-bounded martingales from upcrossings.
- State the drift and minorization conditions under which an MCMC average obeys a CLT with variance sigma squared times tau.
Practice
- Monitor an experiment with a betting test that stays valid at every look, and say what a repeatedly applied z test does instead.
- Report an MCMC mean with a batch-means standard error, and say why the i.i.d. formula understates it.
Contents
Each chapter has a home level. Choose a track to see what to read and watch: Bachelor's 11 min · Master's 18 min · PhD 57 min · Practice 18 min.
- 0Markov counts the vowels of OneginBachelor's4 min
- 1Conditional expectationPhD5 min
- 2MartingalesPhD3 min
- 3Optional stoppingBachelor's4 min
- 4Maximal inequalities and VillePractice4 min
- 5Martingale convergencePhD4 min
- 6Martingale concentrationPhD3 min
- 7The martingale CLTPhD3 min
- 8Markov chains on general spacesPractice3 min
- 9Coupling and mixingPhD5 min
- 10Brownian motionPhD4 min
- 11Donsker's invariance principlePhD4 min
- 12The law of the iterated logarithmPhD3 min
- 13Counting processesPhD4 min
- Recap, problems, and the road aheadAll tracks3 min
Also on this page: Lecture · Key results · Try it · Lab · Problems · Notes and sources · Build the film.
Lecture
The text of each chapter is the film's narration, as it is spoken, so you can read along or revise without the film. The pictures are in the film. A dashed box stands for a number the film computes when it is rendered (hover over it to see what is computed); the README's figures for each chapter, where it lists them, follow the chapter's text.
Markov counts the vowels of OneginBachelor's4 min
In 1902 the Moscow mathematician Pavel Nekrasov argued that the law of large numbers requires independence, and concluded, because social statistics are regular, that human acts must be independent, a proof of free will. In St Petersburg, Andrei Markov strongly disagreed. In 1906 he established a law of large numbers for suitable dependent finite-state chains. A Markov property alone does not guarantee a law of large numbers. And in January 1913, at the two hundredth anniversary of Bernoulli's law, he showed it on real data, by counting the letters of a poem.
The poem was Pushkin's Eugene Onegin, which every Russian reader knew. Markov took its first twenty thousand letters, leaving out the hard and soft signs, which are not sounds, and wrote each as a vowel or a consonant. Here are the first sixty, in the original Russian: gold for vowels, blue for consonants. We redid his count from the public-domain text. It gives vowels, against Markov's , and consonants. With a modern spelling and transcription, this count differs by one; the text version and counting convention matter.
Then he counted pairs. A vowel was followed by another vowel only times, Markov's count was , and two consonants followed each other times, his . So after a vowel the next letter is a vowel with probability ; after a consonant, . Adjacent letters show strong dependence. These fitted probabilities describe a homogeneous first-order model; the poem is not established to be generated by that model. Yet the long-run share of vowels, the chain's stationary probability, , matches the observed share. This near equality follows largely from fitting transitions to the same sequence; it is not independent evidence for a limit theorem.
Markov went further. He cut the text into two hundred blocks of a hundred letters and counted the vowels in each. The counts vary far less than independence would allow: their variance is , against for independent letters. The chain explains most of the difference: alternation makes blocks more alike, and its approximate block-count variance is . The ratios, observed and for the chain, are Markov's dispersion coefficients; he found point two oh eight, and about point three. Under appropriate ergodicity conditions, dependence changes the asymptotic variance while preserving a law of large numbers. The gold normal curve is an approximation, not the exact chain count law. That is the subject of this part.
Three promises are now due. Part forty-three proved its laws for independent summands; chapters five to nine extend them to martingales and chains. Part twenty-seven computed MCMC standard errors by batch means, assuming a central limit theorem for the chain; chapter eight supplies it. And Part thirty-eight used the Dickey–Fuller tables, whose limits are functionals of Brownian motion; chapters ten and eleven build Brownian motion and explain them.
Numbers: P(V | V) = 0.128, P(V | C) = 0.663; π = 0.432; block variance 5.25 vs 24.5 (i.i.d.) and 7.56 (chain)
1Conditional expectationPhD5 min
Conditional expectation, defined properly at last. For integrable X, Kolmogorov's definition: its conditional expectation given the information G is a random variable that depends only on that information, and that has the same integral as X over every event in G. It exists by the Radon–Nikodym theorem: integrating X over the events of G defines a finite signed measure that vanishes wherever P does. Apply Radon–Nikodym to its positive and negative parts; and its density with respect to P restricted to G is the conditional expectation. It is unique up to a null set, and it is a random variable, not a number. When G is generated by a single event B, it takes two values, the elementary averages over B and over its complement when both events have positive probability. Values on null events are arbitrary versions.
For square-integrable X there is a picture. The functions of the information G form a closed subspace of all square-integrable random variables, the plane. X is a vector above it, and its conditional expectation is the foot of the perpendicular: the orthogonal projection. Orthogonality says the error is orthogonal to every square-integrable function of the information, so the conditional expectation is the best prediction of X from G in mean square. Part twelve's least squares projects onto the smaller subspace of linear functions; the conditional expectation projects onto all of them.
Four rules do almost all the work. The tower property: conditioning on more information and then on less is the same as conditioning on less. What is known can be taken out: a bounded function of the information behaves like a constant; more generally the product must be integrable. Information independent of X teaches nothing, and the conditional expectation is the plain mean. And Jensen's inequality holds conditionally when the relevant expectations exist. Every martingale calculation in this part is a few lines of these.
The projection picture gives the law of total variance at once: the variance of X is the expected conditional variance plus the variance of the conditional expectation. It is Pythagoras: X minus its mean splits into two orthogonal pieces, the error of the projection and the projection's own deviation. So replacing an estimator by its conditional expectation given a statistic never increases the unconditional variance of the resulting random variable. To obtain a usable estimator independent of the unknown parameter, Rao–Blackwell conditions on a sufficient statistic. An individual realized conditional variance can exceed the unconditional variance. The same identity gave Rubin's rules in Part forty-one and the split of variance between and within groups in Part twenty-five.
The definition conditions on sigma-algebras, not on events, for a reason. Pick a point uniformly on a sphere. Fix the same half-meridian, y equal to zero and x positive, in both panels. It has probability zero. Approach that half-meridian through a thin longitude wedge. The angle along it has limiting density cosine phi over two, piled up at the equator, because wedges are wider there. Approach the very same half-meridian through a thin geodesic band, absolute y small and x positive. The same angle now has uniform limiting density one over pi. The limiting set and angle are identical; the shrinking neighborhoods differ, so the answers differ. This is Borel's paradox: conditioning on an event of probability zero depends on the family of events it is embedded in, which is exactly what a sigma-algebra specifies.
For whole distributions, one wants a regular conditional distribution: a probability kernel that gives the conditional law of X for each value of Y at once. It exists whenever X takes values in Euclidean space, or any complete separable metric space. The joint law then disintegrates into the law of Y and the kernel. Every posterior distribution in this course was one of these: Bayes's theorem for densities is a disintegration of the joint law of parameter and data, The kernel is unique only for almost every conditioning value under the law of Y. It may still be changed at a particular value of probability zero.
Numbers: Borel's paradox: 6,460 wedge points vs 10,065 geodesic-band points approaching the same half-meridian
2MartingalesPhD3 min
Martingales: a fair game, in symbols. A martingale is a sequence adapted to a growing flow of information, integrable, whose conditional expectation tomorrow, given everything known today, is its value today: a fair game. Sums of steps whose conditional mean is zero are martingales, and the steps need not be independent; that is the whole point. For nonnegative factors, products with conditional mean one are martingales too. Signed products additionally need integrability: a gambler's wealth under fair bets, or a likelihood ratio. And the successive predictions of any fixed integrable random variable, as information arrives, form a martingale named after Joseph Doob, whose 1953 book made the theory.
The statistician's martingale is the likelihood ratio. Test a fair coin against one that lands heads sixty percent of the time, and multiply, toss by toss, the ratio of the two probabilities of what happened. If the coin is fair, each factor has mean one, so the product is a martingale with mean one forever. Nevertheless the typical null path trends down over the long run, with local upward moves: the logarithm drifts at minus the Kullback–Leibler divergence, per toss. After a thousand tosses the median ratio is about one in a billion, while the mean is still one, held up by rare enormous paths. A martingale can converge to zero almost surely while its mean stays fixed. If the coin is biased, the green paths climb instead, at the other divergence. This asymmetry is the engine of sequential testing.
Any adapted integrable sequence splits into a martingale plus a drift, which is the sum of the expected next steps. The drift is predictable: each term is known one step ahead. For the square of a fair random walk, the drift is just n, so S n squared minus n is a martingale. For a square-integrable martingale, applied to its square, the drift is the predictable variation, the sum of conditional variances of the steps: the quantity the martingale central limit theorem and the theory of counting processes are built on.
George Pólya's urn starts with one red ball and one blue. Draw a ball at random, and return it with another of the same colour. The share of red is a martingale, and it is bounded between zero and one; chapter five will show that such a martingale must converge. The theoretical limits have a uniform distribution. Here we simulate two thousand independent urns for six hundred draws, not all the way to their limits. Their terminal shares follow an exact uniform lattice on six hundred and one possible values; the displayed goodness-of-fit check is calibrated to that finite law by Monte Carlo. The colours drawn are exchangeable but not independent: given the limit, they are independent coins with that probability of red. That is de Finetti's theorem from Part five, whose reverse-martingale proof chapter five outlines.
Numbers: likelihood ratios: median wealth 1.4 × 10⁻⁹ after 1,000 tosses, theoretical mean 1 (Monte Carlo 0.98 at 20 tosses); finite-urn calibrated KS p = 0.7421
3Optional stoppingBachelor's4 min
Optional stopping: can you beat a fair game by choosing when to quit? A stopping time is a rule for quitting that uses only the past: whether you have stopped by time n must be decided by time n. Doob's optional stopping theorem: at a stopping time, the expected value of a martingale is its starting value, provided the stopping time is bounded, or the stopped martingale is uniformly integrable and the stopping time is almost surely finite, or the expected stopping time is finite and the steps are bounded. The proof: the martingale stopped at tau is again a martingale, so its mean never changes, and one of the conditions lets the limit pass inside the expectation. No stopping rule can turn a fair game into a favourable one, unless the conditions fail.
The theorem's classic use is the gambler's ruin. Start with a pounds and play a fair game until you reach b or go broke. Your fortune is a martingale with bounded steps, and the exit time has finite mean, so its expected final value is a, which is b times the chance of reaching b. So that chance is a over b, and applying the theorem to the second martingale, S n squared minus n, the expected length of play is a times b minus a. For an unfair game, q over p to the power S n is a martingale, de Moivre's, and it gives the chance of reaching b in closed form. At an American roulette wheel, betting red, the chance of doubling ten pounds before losing them is about a quarter; of doubling a hundred, three in a hundred thousand. A small house edge, compounded over a long game, is decisive.
The exact answers, for a fair coin and for roulette, at three scales. A fair game is fair at every scale: half the time you double your money, and the game lasts a times b minus a rounds. Roulette is not: the larger the target relative to each bet, the more certainly the house wins, though the game ends sooner.
Then why does the doubling strategy, the martingale of the casinos, seem to work? Bet one; after each loss, double the bet; stop at the first win. You always finish exactly one ahead, so the expected final fortune is one, not zero: the optional-stopping equality does not apply. The stopping time is finite, but the conditions are not met: the losses before the first win are unbounded, and their expected size is infinite; in two hundred thousand simulated strategy cycles, one needed over a million in credit. Give the gambler a real bankroll, one thousand and twenty-three, enough for ten losing bets, one through five hundred and twelve, and the theorem applies: on a fair coin the expected gain is exactly zero, many small wins balanced by a rare ruin. At the roulette wheel ruin comes once in about six hundred rounds, and the strategy loses per strategy cycle on average.
For independent identically distributed integrable steps of mean mu, with a stopping time adapted to their history and finite expected duration, S n minus n mu is a martingale, and optional stopping gives Wald's identity: the expected sum at a stopping time is mu times the expected number of steps. Abraham Wald used it in 1945 to compute the expected sample size of his sequential probability ratio test. A stopping rule based on the data can change frequentist calibration. Its likelihood contribution is parameter independent when the stopping mechanism is parameter free; under that condition the likelihood remains proportional to the fixed-sample likelihood; Part fifty-eight will reconcile the two views with martingales.
Numbers: roulette 10 → 20: 0.259; 50 → 100: 0.0051; 100 → 200: 2.7 × 10⁻⁵; doubling: ruin 0.0016, EV −0.67
4Maximal inequalities and VillePractice4 min
Maximal inequalities: how high can a fair game climb? Doob's maximal inequality generalizes Kolmogorov's from the last part: the chance that a submartingale ever climbs above lambda before time n is at most the expected positive part at time n, over lambda. The proof stops at the first time the path crosses lambda; optional stopping, with a bounded time, does the rest. Its L p version bounds the whole running maximum by a constant times the final value, for every p above one. A martingale cannot wander far without its final value showing it.
The infinite-horizon version is older, and statistically the most important. In 1939 Jean Ville, criticizing Richard von Mises's definition of a random sequence, took the casino word martingale for a betting system and made it mathematics. His idea: a sequence is random if no betting system, playing fair odds against it, can get rich. And he proved the inequality that makes that idea quantitative.
Let M be a nonnegative martingale, or supermartingale, starting at one under the null hypothesis: the wealth of someone betting against the null at fair odds, a likelihood ratio for instance. Ville's inequality: the chance that it ever reaches one over alpha, at any time at all, is at most alpha. It is Doob's inequality for each n, with the limit taken over all n. Read as a test: bet against the null, watch your wealth, and reject when it reaches one over alpha. You may look after every observation and stop whenever you like, and the false alarm rate is still at most alpha. Part fifty-eight builds modern anytime-valid inference on this one line.
Here is the test, drawn with this part's betting-paths instrument. A gambler bets against a fair coin, putting her wealth on heads at the odds a sixty percent coin would deserve. Forty of four thousand wealth paths under the null, on a log scale: most sink towards zero. The red line is wealth ten, one over alpha for alpha a tenth. Of the four thousand paths, percent ever touched it within a thousand tosses, inside Ville's ten percent; The theorem bounds the true infinite-horizon crossing probability by ten percent, not the exact fraction in every finite simulation. Against a coin that really is biased, wealth grows exponentially, and the line is crossed early. This long-run log-wealth growth helps explain power, although it is not itself a finite-sample power calculation: the Kullback–Leibler divergence again.
Ville's inequality turns wealth into p-values. Include the initial wealth of one. One over the running maximum is then an anytime-valid p-value: under the null, the chance it ever falls below alpha is at most alpha, whatever stopping rule the analyst follows, even one chosen after looking. The wealth at a stopping time is itself an e-value: for finite stopping times its expectation is at most one. An infinite stopping time needs the nonnegative supermartingale limit and Fatou's lemma. Unlike p-values, e-values from independent studies can simply be multiplied, Conditional validity also allows sequential products. A study can continue after an interim look while following the same valid wealth process; choosing a new favorable bet after seeing its outcomes is not licensed. Part fifty-eight is built on them.
Numbers: 8.2% of 4,000 null paths ever reach wealth 10 (≤ 10%)
5Martingale convergencePhD4 min
Martingale convergence: why a bounded fair game must settle down. The convergence theorem rests on counting upcrossings: climbs of the path from below a level a to above a level b. This seeded illustration makes three completed upcrossings. The seed was chosen for visibility, not for estimating how often crossings occur. Doob's upcrossing inequality: the expected number of upcrossings is at most the expected positive part of M n minus a, over b minus a. The proof is a betting system: buy when the path falls below a, sell when it rises above b. Each completed climb earns at least b minus a, and a fair game cannot pay for unboundedly many.
Doob's convergence theorem: a martingale bounded in absolute first moment converges almost surely, to a finite limit. If it did not, for some rational pair a below b it would oscillate across them infinitely often, and the upcrossing inequality makes that a null event; there are only countably many rational pairs. Convergence in mean needs more: uniform integrability, which is equivalent to the martingale being the successive predictions of its own limit. So every non-negative martingale converges, and every uniformly bounded one, or one dominated by an integrable envelope, converges in mean too. Merely being bounded separately on each sample path is insufficient.
Two martingales from chapter two show the difference. Pólya's urn is bounded, hence uniformly integrable: its random limit has mean one half, the starting share. The likelihood ratio under the null is non-negative, so it converges too, and its limit is zero. Its mean is one at every n, but the mean of its limit is zero: it is not uniformly integrable. Its mass escapes along ever rarer paths of ever larger wealth, Part forty-three's escaping bump in the form of a martingale.
Paul Lévy's upward theorem: the predictions of any integrable X, as information grows, converge to its prediction given the sigma-algebra generated by the union of these information sets. In particular the conditional probability of any event decided in the limit tends to one or zero: you eventually learn whether it happens. A Bayesian posterior mean is such a sequence of predictions: a Doob martingale. If the parameter is integrable, the model satisfies the standard measurability conditions, and the parameter is measurable from the infinite data, the posterior mean converges to it. That is Doob's 1949 theorem: posterior consistency, for almost every parameter value under the prior. Part fifty-three asks the harder question, for every parameter value.
Martingales also run backwards. For independent identically distributed integrable variables, let E n be the information in the n-th partial sum and everything after it, which shrinks as n grows. By symmetry, each of the first n variables has the same conditional expectation given it, so the sample mean is the conditional expectation of the first variable: a reverse martingale. Reverse martingales always converge, here to the expectation given the exchangeable sigma-algebra, which by Hewitt and Savage is trivial: the strong law of large numbers again, in four lines. For an exchangeable sequence extending the argument to bounded indicator functions and their products establishes conditional factorization given the limiting empirical law. The sample-mean convergence alone does not prove conditional independence. This outlines de Finetti's theorem, promised in Part five.
Numbers: upcrossings; Pólya's urn settles; reverse martingales and the strong law
6Martingale concentrationPhD3 min
Concentration for martingales: Hoeffding's inequality without independence. Part six's Hoeffding inequality needed independence. Martingales do without it. Suppose each step has absolute value bounded by a deterministic c k. Hoeffding's lemma, applied conditionally, bounds the conditional moment generating function of each step. The tower property peels the steps off one at a time, from the last to the first. Chernoff's method then gives the Azuma–Hoeffding inequality: a Gaussian tail with variance proxy the sum of the squared bounds, for any martingale at all.
The most useful consequence is Colin McDiarmid's. Take any function of independent inputs that changes by at most c i when the i-th input changes. Reveal the inputs one at a time: the successive predictions of f form a Doob martingale whose steps are bounded by the c's. So f concentrates around its mean with a Gaussian tail, for functions far too complicated to analyse directly: the number of empty bins, the longest increasing subsequence of a random permutation, the chromatic number of a random graph, or the risk of a learned predictor in Part fifty-four.
Why the constant two in McDiarmid's bound, not the one half of Azuma's? Look at one martingale step: what is learned by revealing the k-th input. Because the inputs are independent, the step lies in an interval of length c k whose position is already known from the earlier inputs. Hoeffding's lemma for a variable confined to a range of length c gives the sharper exponent, lambda squared c squared over eight. Multiplying through the steps and optimizing lambda yields e to the minus two t squared over the sum of the c k squared.
A test. Throw a thousand balls into a thousand bins at random and count the empty bins. Its mean is n times one minus one over n to the n, about , and simulation gives a standard deviation of about ten. Moving one ball changes the count by at most one, so McDiarmid applies with every c equal to one. In blue, the simulated tail probabilities on a log scale; in gold, the bound. The bound always holds and has the right Gaussian shape, but it is loose: it uses only the worst-case change of one ball, Its sub-Gaussian variance proxy corresponds to a scale near sixteen, rather than the actual standard deviation near ten. A finite Monte Carlo curve also has sampling error. Inequalities that use the variance do better.
David Freedman's inequality of 1975 uses the variance. If the steps are bounded by c and the predictable variation is at most v, the tail is bounded by the exponential of minus t squared divided by two times the quantity v plus c t over three. It is Bernstein's inequality for martingales: when the steps are usually small, the variance rather than the range sets the scale. It is the workhorse of the proofs for bandits and sequential tests in Part fifty-eight.
Numbers: empty bins: mean 367.7, SD 9.9; McDiarmid scale proxy ≈ 16, not the actual SD
7The martingale CLTPhD3 min
The martingale central limit theorem. Lindeberg's theorem has a martingale version. Take a triangular array of martingale differences: each step has conditional mean zero given the past. Suppose the sum of the conditional variances converges in probability to one, and a conditional Lindeberg condition holds, so no single step matters. Then the sum is asymptotically standard normal. Don McLeish gave a short proof in 1974, and Peter Hall and Christopher Heyde's book of 1980 made it the standard tool. The first condition is the crucial one: the information collected must become predictable.
Its most common use is invisible: many time-series standard errors under their regularity conditions. Take Part seventeen's first-order autoregression. For the zero-mean fit without an intercept, the least-squares error is exactly a ratio whose numerator, the sum of y t minus one times e t, is a martingale, because each new shock is unpredictable from the past. The terms are not independent: y t minus one is built from earlier shocks. The conditional variances add up to sigma squared times the sum of squared lags, which settles, divided by n, by the ergodic theorem, when phi is below one in absolute value. So root n times the error is normal with variance one minus phi squared, under the stationary finite-moment assumptions. Fitting an intercept has the same leading limit here, rather than the exact same finite-sample ratio.
The same theorem also applies to regular conditional likelihoods for dependent data. The score of a process is a sum over observations of the derivative of each conditional log-density given the past. When the support and differentiation-under-the-integral conditions hold, each term has conditional mean zero, by Part twenty-two's argument applied conditionally, so the score is a martingale. Its predictable variation is the conditional information, the sum of the conditional variances. If that settles to a deterministic nonsingular limit after scaling and the conditional Lindeberg condition holds, the martingale central limit theorem makes the standardized score normal. A Taylor argument also needs identification, consistency and Hessian convergence for asymptotic normality of the maximum likelihood estimator. Some branching-process and nonstationary models instead have random information or other limits.
Twenty thousand simulated series, fitted as practice fits them, with an intercept. With phi a half and two hundred observations, the standardized estimate is close to normal. With phi point nine eight and a hundred observations, it is skewed to the left and biased: the mean estimate is . For fixed point nine eight the stationary central limit theorem still holds eventually; this sample is too short for a good approximation. The approximation is not uniform as phi approaches one. At phi equal to one the scaling and limit change: it is Dickey and Fuller's functional of Brownian motion, chapter eleven's subject.
Numbers: AR(1): φ = 0.5 covered 89.9%, skew −0.22; φ = 0.98 covered 70.0%, skew −1.25
8Markov chains on general spacesPractice3 min
MCMC samplers run on continuous spaces, where a chain need not return to an individual point. Metropolis rejections can keep it at exactly the same point. Their theory replaces states by sets. A small set is a region from which the next step always has at least a fixed chance of being drawn from one fixed law nu: a minorization. A Harris recurrent chain hits every set of positive stationary probability infinitely often, from any start. And the minorization lets one split the chain: each visit to the small set, a coin with probability epsilon decides whether the next step is a fresh draw from nu, a regeneration. after the initial incomplete tour, successive regeneration tours are independent and identically distributed, which turns a dependent chain back into Part forty-three's independent sums.
Speed comes from a drift condition. Find a function V, at least one, whose expected next value shrinks by a factor lambda below one, except on a small set. For a psi-irreducible aperiodic chain with the stated small-set drift and finite V, Sean Meyn and Richard Tweedie's theory shows that the chain converges to its stationary law geometrically fast in total variation, from any start, at a rate depending on V of the start. For the AR one chain, one plus x squared works for Gaussian noise of positive variance when absolute phi is below one. Choose lambda strictly between phi squared and one, and a sufficiently large compact small set. And it can fail: random-walk Metropolis on a target with tails as heavy as the Cauchy's is not geometrically ergodic, as Kerrie Mengersen and Tweedie showed in 1996; its excursions into the tails take too long to come back from.
For a geometrically ergodic chain and a function with a little more than two moments under the target, the MCMC average satisfies a central limit theorem, proved through the regenerations or through martingale approximation. Its variance is the target variance times the integrated autocorrelation time, tau: one plus twice the sum of the autocorrelations. Batch means, spectral estimates and effective sample sizes, all used in Part twenty-seven, are ways of estimating it. The theorem is what makes them estimates of something.
A random-walk Metropolis chain for a standard normal, with small steps: percent are accepted, and the trace wanders slowly. Its autocorrelations decay over dozens of lags; a positive-lag truncation through lag sixty gives an approximate autocorrelation time of . From two hundred thousand iterations, the standard error of the mean by the independent-draws formula is ; thirty finite batches give the approximate standard error , and the autocorrelation correction . Ignoring the dependence understates this estimated error about five-fold. These finite-batch and truncated autocorrelation estimates are approximate; consistency of batch means requires both batch length and the number of batches to grow.
Numbers: RWM: τ = 23; SE 0.0022 (i.i.d.) vs 0.0104 (batch means)
9Coupling and mixingPhD5 min
Coupling and mixing: how long until a chain forgets where it started? For finite chains we can measure exactly how far a chain is from stationarity after t steps: the total variation distance from the worst start. The mixing time is when it first falls below a quarter. Wolfgang Doeblin's device for bounding it is coupling: run two copies, one from x and one from the stationary law, on a shared source of randomness, so that once they meet they move together. The distance at time t is at most the chance they have not yet met. And if, after m steps, every start has at least an epsilon chance of being drawn from the stationary law, the distance decays geometrically. The lab computes finite-chain distances exactly up to floating-point error and estimates coupling tails by Monte Carlo.
The lazy random walk on a cycle of twenty sites: at each step stay put with probability one half, else move to a neighbour. In blue, its exact distance from the uniform law, from a fixed start; it falls below a quarter after steps. In gold, the chance that the classical coupling has not yet joined: two walkers, a coin deciding which one moves, so their gap does a random walk until it closes, on average after n squared over four, a hundred steps. The opposite-start gap is the worst separation for this coupling. Its survival probability dominates other initial gaps; averaging the second start over stationarity therefore bounds total variation. The plotted four-thousand-run estimate has Monte Carlo error. The spectral gap, one minus the second eigenvalue, gives the relaxation time, . All of them grow like n squared: on a cycle, mixing is diffusion.
A walk on the corners of a d-dimensional cube: at each step pick a coordinate and reset it with a fair coin. With ten dimensions it mixes in steps; with forty, in : of order d log d, not d squared, and, plotted against steps per dimension, the drop sharpens as d grows: the distance stays near one, then falls almost at once. Persi Diaconis named it the cutoff phenomenon. Two plotted dimensions illustrate sharpening; cutoff is an asymptotic statement about a family of chains. The cube has two to the forty corners, but from the all-zeros start only the number of ones matters, so the exact computation needs forty-one states.
The most famous mixing time is a card trick. Model a riffle shuffle as Gilbert, Shannon and Reeds did: cut the deck binomially and drop cards from the two halves in proportion to their sizes. Dave Bayer and Persi Diaconis found, in 1992, that after k shuffles the probability of an order depends only on its number of rising sequences, through a single binomial coefficient. That makes the distance from a uniform deck computable exactly over all fifty-two factorial orders. The lab does it: the distance stays at one for four shuffles, falls to at six, and at seven, the first time it is below a half. Hence the headline: seven shuffles suffice. A casino that shuffles three times deals a deck that is still, in total variation, highly distinguishable from a uniform deck by some events. Total variation near one does not mean each card or the complete order can be perfectly predicted.
Whether a chain returns at all is the question George Pólya answered in 1921, after meeting the same couple again and again on his walks in a Zürich park. A simple random walk on the line returns to its start with probability one. On the plane it also returns surely, but so slowly that after ten thousand steps over a quarter of walks are still out. In three dimensions it returns with probability only point three four: it is transient. The saying attributed to Shizuo Kakutani puts it best: a drunk man will find his way home, but a drunk bird may get lost forever.
Numbers: cycle n = 20: t_mix 38, relaxation 40.9; hypercube t_mix 16 (d = 10), 91 (d = 40); 7 shuffles: TV 0.334
10Brownian motionPhD4 min
Brownian motion: a continuous path made of independent pieces. Brownian motion starts at zero and has independent Gaussian increments, each with variance equal to the time elapsed. And its paths are continuous. Kolmogorov's extension theorem builds a process with the right finite-dimensional laws, but, as Part forty-three warned, its sigma-algebra cannot even ask whether a path is continuous. Norbert Wiener built the measure on continuous paths directly in 1923. The simplest construction is Lévy's, refined by Ciesielski.
Start with a straight line from zero to a normal value at time one. At the midpoint, add a tent whose height is an independent normal scaled so that the midpoint has the right conditional variance; then add tents at the quarter points, the eighths, and so on. The tents are Schauder functions, the integrals of the Haar wavelets of Part twenty-nine. Here are levels zero, one, two, three, five and ten. Because the tents at level n are of size two to the minus n over two, and normal maxima grow only like root log, the series converges uniformly, almost surely: the limit is continuous, and it is Brownian motion.
Brownian motion is self-similar: speed up time by c and shrink space by root c, and the process is unchanged in law. Its difference quotients over a step h are normal with variance one over h, which explodes as h shrinks: this suggests roughness at a fixed time, but it does not by itself prove nowhere differentiability. Paley, Wiener and Zygmund proved in 1933 that, almost surely, there is no time at all at which it is differentiable: a continuous, nowhere differentiable function, chosen at random. It is a Markov process, and three martingales come with it: B itself, B squared minus t, and the exponential martingale, the continuous-time likelihood ratio.
The martingales give exit problems at once. Let tau be the first time Brownian motion leaves the interval from minus b to a. The stopped path is bounded, so optional stopping applies: the expected exit position is zero, and the chance of leaving at the top is b over a plus b. For B squared minus t, first stop at tau or n, whichever comes first. The bounded exit interval bounds the expected stopped time; monotone convergence gives an integrable exit time, and dominated convergence then gives the expected exit time, a times b. These are exactly chapter three's gambler's-ruin answers, for a game whose steps have shrunk to nothing: a preview of the next chapter.
One more property makes Brownian motion unlike any smooth path. Cut the unit interval into N pieces and add up the squared increments: along deterministic partitions whose mesh tends to zero the sum converges in probability to one; along nested dyadic partitions it converges almost surely. The displayed quadratic-variation calculation uses a separate simulated fine path. That is the quadratic variation. The absolute increments, by contrast, add up to something growing like root N: the path has infinite length. In shorthand, dB squared equals dt, the rule from which Itô's stochastic calculus grows, and the subject of this channel's series Stochastic Calculus, Visualized.
Numbers: Σ(ΔB)² = 0.911 at 1,024 pieces, 0.992 at 65,536; Σ|ΔB| = 24.5 → 203.7
11Donsker's invariance principlePhD4 min
Donsker's invariance principle: centered finite-variance random walks, seen from far away. Take a random walk of n steps of plus or minus one, squeeze its time axis by n and its space axis by root n. Here it is with ten, a hundred and a thousand steps. The individual steps disappear, but the wiggles remain of the same size at every scale: the picture converges to a Brownian path.
Monroe Donsker's theorem makes that exact, for independent identically distributed steps with mean zero and finite positive variance, standardized to variance one. The rescaled walks converge weakly to Brownian motion, as step paths in the Skorokhod space with its J-one topology, or as linearly interpolated paths in the continuous-path space: a central limit theorem for whole functions, and the reason Brownian motion appears whatever the steps. By the continuous mapping theorem, a functional continuous at almost every Brownian path, such as the maximum or integral, or the time above zero since the Brownian zero set has zero Lebesgue measure, converges to the same functional of Brownian motion. One proof embeds the walk in a single Brownian path, observed at a sequence of stopping times, Skorokhod's embedding, which makes the walk and the path close almost surely.
An example. Reflect a Brownian path in the level x after it first touches it; by symmetry the reflected path is just as likely, so the chance that the maximum up to time one exceeds x is twice the chance that the endpoint does. By Donsker, the maximum of a long random walk approaches this law. Twenty thousand discrete walks of a thousand steps show finite-step and Monte Carlo discrepancies: at x equal to one, against . A hard combinatorial question about walks is answered by a one-line symmetry of Brownian motion.
Donsker's theorem has a second form, the one he proved it for. The empirical CDF's error, scaled by root n, is a normalized sum of centred indicators, a random function of u. It converges to the Brownian bridge: Brownian motion tied back down to zero at time one. So the Kolmogorov–Smirnov statistic converges to the maximum of the bridge, whose law, Kolmogorov's alternating series, gives the KS test of Part sixteen its critical values, the same for every fixed, fully specified continuous F. Fitting distribution parameters changes the null calibration. Part forty-eight builds the general theory: empirical processes.
And the promise from Part thirty-eight. For a unit-root regression with neither an intercept nor a trend, the least-squares estimate of rho, scaled by n rather than root n, converges to B one squared minus one, over twice the integral of B squared. First use the exact identity: twice the sum of lagged y times the innovation equals the final y squared minus the sum of squared innovations. The law of large numbers makes that last sum over n tend to the innovation variance. Donsker and the continuous mapping theorem then give the displayed ratio. Donsker alone does not justify convergence of the stochastic integral. Twenty thousand simulated random walks of two hundred and fifty steps: the Dickey–Fuller t statistic is skewed left, negative percent of the time, with a five percent point of . This no-intercept, no-trend limit has a five-percent critical value about minus one point nine four; adding an intercept changes it to about minus two point eight six. Here the normal would say minus one point six four five. The critical values of Part thirty-eight are quantiles of Brownian functionals.
Numbers: reflection 0.311 vs 0.317; Dickey–Fuller 5% point −1.95; 68% of t's negative
12The law of the iterated logarithmPhD3 min
The law of the iterated logarithm: exactly how far a random walk strays. The central limit theorem describes S n over root n at one time at a time. But a path is checked at every time, and at some times it will be unusually far out. Aleksandr Khinchin's law of the iterated logarithm, for coin tosses in 1924, says exactly how far: the upper limit of S n over the root of two n log log n is one, almost surely. The lower limit is minus one, and, as Volker Strassen showed, every point in that interval is a subsequential limit: the ratios get arbitrarily close, not necessarily exactly equal, infinitely often. Philip Hartman and Aurel Wintner extended it in 1941 to independent identically distributed mean-zero steps with finite variance, after division by their positive standard deviation.
For bounded fair-coin steps, the upper half of the proof is the strong law's trick again. Check the walk only at geometric times, theta to the k. Between two such times, a maximal inequality bounds the chance of ever exceeding c times the envelope by a Gaussian tail. Because the envelope contains log log n, that tail is a power of k: k log theta to the minus c squared over theta, which is summable exactly when c squared exceeds theta. That is where the iterated logarithm comes from. Borel–Cantelli then bounds the upper limit by c, and letting c and theta shrink to one gives one. The lower half uses the second Borel–Cantelli lemma on independent separated blocks. Extending this argument to general finite-variance steps also requires truncation.
Six random walks of a million steps, divided by root n. For a sufficiently large fixed n, the central limit theorem approximately puts ninety percent of walks inside the grey lines. But each path, followed over time, keeps escaping them, out to the gold envelope, the root of two log log n, which grows without bound. The largest excursion of each path relative to the envelope, after the first thousand steps, is between and : these are descriptive finite-window maxima. Taking a maximum from a fixed starting time can preserve an early overshoot forever, so these numbers do not estimate a sequence converging to one. Log log n grows so slowly that, for a million steps, the envelope is only about two point three standard deviations.
The statistical lesson is the one chapter four drew from Ville. An interval valid at one sample size is not valid at every sample size simultaneously. Watch a fixed-sample interval forever and, by the iterated logarithm, it will eventually exclude the truth, almost surely. For intervals centered at an efficient sample mean, an asymptotic boundary of order one over root n must acquire a root log log n factor for all-time coverage. This is not a universal width theorem for every possible test or interval construction. Such intervals, confidence sequences, are built from Ville's inequality in Part fifty-eight.
Numbers: ratios of the running maximum to √(2n log log n): 0.76–1.27
13Counting processesPhD4 min
Counting processes: the martingales inside survival analysis. A counting process counts events as they happen: deaths in a cohort, relapses in a trial. Its compensator is the integral of the number at risk times the hazard: an accumulated predictable intensity, rather than in general the conditional expectation of the full count at time t. The difference, counts minus compensator, is a martingale, and its predictable variation is the compensator itself. Under nonexplosion and suitable integrability, this gives a true martingale; otherwise localization may be needed. Odd Aalen's 1978 paper made this the foundation of survival analysis. It is chapter two's Doob decomposition in continuous time, the Doob–Meyer decomposition.
Two hundred simulated lifetimes with hazard one, censored at random times: events. In blue the count of events, in gold its compensator, the integral of the number still at risk. The two climb together. On the right, their difference, the martingale. It wanders around zero inside plus or minus two times the root of the compensator, an illustrative band rather than a guaranteed ninety-five percent interval. The compensator is the bracket, not a pathwise conditional variance. The martingale ends at after more than a hundred events.
The payoff is in Part forty's methods. Here is the placebo arm of the 6-MP trial. The Nelson–Aalen estimator adds, at each event time, the number of events over the number at risk. Its error, Nelson–Aalen minus the cumulative hazard stopped when the risk set is empty, is a stochastic integral against the counting-process martingale. Its predictable variation integrates the true intensity over the squared risk set. The sum of observed events over the risk set squared estimates that bracket; it is not the predictable bracket itself. This gives an approximate pointwise normal band. These recorded times contain ties; the usual grouped-event convention is an approximation to the continuous event-time model. The estimated cumulative hazard of at twenty-three weeks, with standard error .
The log-rank test of Part forty is a stochastic integral too. Take the counting processes of two groups with their numbers at risk. The log-rank statistic integrates, over time, the events in group one weighted by the share at risk in group zero, minus the reverse: observed minus expected. Under the null of equal hazards the compensators cancel exactly, and what is left is an integral of predictable weights against the two martingales. Its bracket uses the common true hazard. Replacing intensity increments by observed events gives a variance estimator; tied groups require the finite-population correction used in Part forty. Rebolledo's theorem, next, makes it normal.
Rolando Rebolledo's central limit theorem for counting-process martingales completes the picture. If normalized predictable variations converge to a deterministic continuous limit and a Lindeberg or equivalent small-jump condition holds, the martingales converge to a Gaussian martingale. Applied to stochastic integrals, it supports asymptotic normality for suitably normalized Kaplan–Meier and Nelson–Aalen estimators, log-rank scores, and regular Cox coefficient estimates. Independent censoring, predictable entry, adequate risk sets and the relevant identification and regularity conditions are still needed. A variance formula or likelihood is not itself an asymptotically normal estimator. The theory is set out in the book by Andersen, Borgan, Gill and Keiding. Every standard error in Part forty was, underneath, a martingale calculation.
Numbers: 200 lifetimes, 118 events; 6-MP placebo Nelson–Aalen 3.53 (SE 1.25) at 23 weeks
Recap, problems, and the road aheadAll tracks3 min
Part forty-four in twelve lines. Markov counted Onegin's letters to show that the law of large numbers survives dependence. Conditional expectation is a Radon–Nikodym derivative and, for square-integrable variables, a projection. Martingales are fair games: likelihood ratios under the null, Pólya's urn. Optional stopping cannot beat a fair game, unless its conditions fail, as the doubling strategy does. Ville's inequality bounds a nonnegative martingale's chance of ever growing large, which makes betting a valid test at any time. Upcrossings make martingales converge, and reverse martingales prove the strong law and outline de Finetti through conditional factorization. Azuma and Freedman control adapted increments; McDiarmid controls functions of independent inputs. and the martingale central limit theorem gives normal limits, until a unit root breaks it. Drift, minorization, irreducibility, aperiodicity and suitable moments give the stated MCMC central limit theorem. Coupling measures mixing, seven Gilbert–Shannon–Reeds riffles bring total variation below one half, and random walks return in two dimensions but not three. Brownian motion is the standardized limit of centered independent finite-variance walks, which explains Dickey and Fuller. And the iterated logarithm and counting processes close the part.
A promise for the next part. This one built the tools for limits in time. But an estimator is not judged by its limit alone: at a finite sample size, some estimators are better than others, and some can be proved best. Part forty-five is the theory of estimation: sufficiency, unbiasedness, the Cramér–Rao bound, and statistical decision theory.
Where it comes back. Part forty-five's Rao–Blackwell theorem is a conditional expectation. Part forty-seven treats the score as a martingale. Part forty-eight extends Donsker's theorem to empirical processes. Part fifty-three goes beyond Doob's posterior consistency. And Part fifty-eight builds e-values and confidence sequences from Ville's inequality.
Six problems, with full solutions in the README. Conditional expectation as the best predictor; the expected length of a fair game; de Moivre's martingale; a two-state chain's stationary law and autocorrelations; McDiarmid for empty bins; and the Nelson–Aalen bracket and its observed-event variance estimator. Pause here if you want to try them.
The books this part follows: Williams's Probability with Martingales and Durrett; Meyn and Tweedie, and Hall and Heyde; Levin, Peres and Wilmer on mixing times; and Andersen, Borgan, Gill and Keiding on counting processes; with the papers from Markov's Onegin to Bayer and Diaconis's shuffles.
Forty-four parts of sixty-five. Randomness that unfolds in time has its own theorems: fair games, chains that forget, and the Brownian limit under finite-variance invariance conditions. Next, Part forty-five: the theory of estimation.
Where it goes next. Rao-Blackwell as a conditional expectation and Brown's use of Polya's recurrence come in Part 45; the score as a martingale in Part 47; Donsker for classes of functions and the Brownian bridge in Part 48; McDiarmid in Part 54; Ville's inequality becomes e-values and confidence sequences in Part 58.
Key results
The part's results in one place, for revision.
Try it
Lab 44 · Fair games in time: Ville's inequality, gambler's ruin and coupling
Watch 10,000 likelihood-ratio wealth paths under a fair coin for 1,000 tosses and count how many ever reach wealth 10, against a z test that peeks every tenth toss; then check gambler's ruin against optional stopping, and the lazy walk's distance from uniform against the tail of a coupling time.
python -m videos.stats.labs 44
needs numpy, scipy, matplotlib · download lab44.py ·
source on GitHubwealth paths ever reaching 10 in 1,000 tosses 9.4% (Ville: at most 10%)
z test at the last toss only, size 10% 9.1% (nominal 10%)
z test at every 10th toss, size 10% each 59.7% false alarms
mean wealth at toss 20 1.003 (a martingale: 1)
fair coin: P(10 becomes 20) 0.500 (theory 0.500)
fair coin: mean number of bets 100.1 (theory 100.0)
roulette, red (18/38): P(10 becomes 20) 0.259 (theory 0.259)
roulette, red (18/38): mean number of bets 92.0 (theory 91.8)
lazy cycle of 20: mixing time, relaxation time 38, 40.9
mean coupling time 98.6 (theory (20/2)^2 = 100)
A fair bet stays fair under any stopping rule: the wealth test keeps its 10% under continuous monitoring while the peeking z test does not, and a coupling time bounds the distance to stationarity.
The code (91 lines; it asserts its own result)
"""Lab 44: bet against a fair coin, stop when you like, and check Ville, optional stopping and the coupling bound."""
import numpy as np
from videos.coursekit import labs
from explainer.stats.kit import chains
TITLE = "Fair games in time: Ville's inequality, gambler's ruin and coupling"
GOAL = ("Watch 10,000 likelihood-ratio wealth paths under a fair coin for 1,000 tosses and count how many ever reach "
"wealth 10, against a z test that peeks every tenth toss; then check gambler's ruin against optional stopping, "
"and the lazy walk's distance from uniform against the tail of a coupling time.")
TASKS = [
"Make the coin truly biased (p = 0.55) and plot the time at which wealth first reaches 10. How does it depend on the bet p1?",
"Let the z test peek at every toss instead of every tenth. How large does its false alarm rate become by n = 1,000, and by 10,000?",
"Change the cycle's length from 20 to 40. By what factor do the mixing time and the mean coupling time grow?",
]
def run(seed=0):
rng = np.random.default_rng(seed)
lab = labs.Lab()
# 1. Ville: a nonnegative martingale started at 1 reaches 1 / alpha with probability at most alpha, at any time.
reps, n, alpha = 10_000, 1000, 0.10
x = rng.random((reps, n)) < 0.5
wealth = chains.betting_paths(x, 0.5, 0.6)
cross = float(np.mean(wealth.max(axis=1) >= 1 / alpha))
looks = np.arange(10, n + 1, 10)
heads = np.cumsum(x, axis=1)[:, looks - 1]
z = (heads - looks / 2) / np.sqrt(looks / 4)
peek = float(np.mean(np.any(np.abs(z) > 1.6449, axis=1)))
fixed = float(np.mean(np.abs(z[:, -1]) > 1.6449))
lab.row("wealth paths ever reaching 10 in 1,000 tosses", f"{cross:.1%} (Ville: at most {alpha:.0%})")
lab.row("z test at the last toss only, size 10%", f"{fixed:.1%} (nominal 10%)")
lab.row("z test at every 10th toss, size 10% each", f"{peek:.1%} false alarms")
lab.row("mean wealth at toss 20", f"{wealth[:, 19].mean():.3f} (a martingale: 1)")
assert cross <= alpha + 0.01, "Ville's inequality (0.01 is three Monte Carlo standard errors)"
assert abs(wealth[:, 19].mean() - 1) < 0.05, "the wealth is a martingale with mean 1"
assert abs(fixed - 0.10) < 0.02 and peek > 0.4, "peeking breaks the fixed-sample test"
# 2. Optional stopping: P(reach b before 0) from a, for a fair coin and for red at American roulette.
a, b, m = 10, 20, 20_000
sims = {}
for name, p in (("fair coin", 0.5), ("roulette, red (18/38)", 18 / 38)):
pos, t, alive = np.full(m, a), np.zeros(m), np.ones(m, bool)
while alive.any():
pos[alive] += np.where(rng.random(alive.sum()) < p, 1, -1)
t[alive] += 1
alive = (pos > 0) & (pos < b)
th = chains.ruin(p, a, b)
sims[name] = (float(np.mean(pos == b)), float(t.mean()), th)
lab.row(f"{name}: P(10 becomes 20)", f"{sims[name][0]:.3f} (theory {th['win']:.3f})")
lab.row(f"{name}: mean number of bets", f"{sims[name][1]:.1f} (theory {th['duration']:.1f})")
assert abs(sims[name][0] - th["win"]) < 0.015 and abs(sims[name][1] / th["duration"] - 1) < 0.04, "ruin"
# 3. Coupling: max_x ||P^t(x, .) - pi||_TV <= P(coupling time > t) on the lazy cycle of 20.
k = 20
P = chains.lazy_cycle(k)
pi = np.full(k, 1 / k)
ts = np.arange(0, 301, 2)
d = chains.distance_curve(P, pi, ts[1:], starts=[0])
d = np.concatenate([[1 - 1 / k], d])
tau = chains.coupling_time_cycle(k, 1500, rng)
tail = np.array([np.mean(tau > t) for t in ts])
tmix, relax = chains.mixing_time(P, pi, starts=[0]), 1 / chains.spectral_gap(P)
lab.row("lazy cycle of 20: mixing time, relaxation time", f"{tmix}, {relax:.1f}")
lab.row("mean coupling time", f"{tau.mean():.1f} (theory (20/2)^2 = 100)")
assert np.all(d <= tail + 0.04), "the coupling inequality"
assert abs(tau.mean() - 100) < 8, "the gap is a fair walk from 10 to 0 or 20"
lab.note = ("A fair bet stays fair under any stopping rule: the wealth test keeps its 10% under continuous "
"monitoring while the peeking z test does not, and a coupling time bounds the distance to stationarity.")
fig, ax = labs.figure(2, size=(11, 4.3))
hit = wealth.max(axis=1) >= 1 / alpha
steps = np.arange(1, n + 1)
for i in range(40):
ax[0].semilogy(steps, wealth[i], lw=0.7, alpha=0.9 if hit[i] else 0.45, color=labs.GOLD if hit[i] else labs.BLUE)
ax[0].axhline(1 / alpha, color=labs.RED, ls="--", label="wealth 10 = 1 / alpha")
ax[0].plot([], [], color=labs.BLUE, label="wealth paths under a fair coin")
ax[0].plot([], [], color=labs.GOLD, label=f"paths that reach 10 ({cross:.1%} of all)")
ax[0].set(title="Betting on heads at a 60% coin's odds", xlabel="toss", ylabel="wealth (log scale)", ylim=(1e-12, 1e3))
ax[0].legend(loc="lower left")
ax[1].plot(ts, d, color=labs.BLUE, label="distance from uniform, exact")
ax[1].plot(ts, tail, color=labs.GOLD, label="P(coupling time > t), simulated")
ax[1].axhline(0.25, color=labs.MUTED, ls=":", lw=1)
ax[1].axvline(tmix, color=labs.MUTED, ls=":", lw=1)
ax[1].text(tmix + 4, 0.28, f"t_mix = {tmix}", color=labs.MUTED, fontsize=9)
ax[1].set(title="Lazy walk on a cycle of 20: coupling bounds mixing", xlabel="steps t", ylabel="total variation")
ax[1].legend()
lab.fig = fig
return lab
Now change it
- Make the coin truly biased (p = 0.55) and plot the time at which wealth first reaches 10. How does it depend on the bet p1?
- Let the z test peek at every toss instead of every tenth. How large does its false alarm rate become by n = 1,000, and by 10,000?
- Change the cycle's length from 20 to 40. By what factor do the mixing time and the mean coupling time grow?
Problems, with solutions
Try each problem before opening its solution.
-
Conditional expectation as the best predictor. Show that \(E[X \mid \mathcal G]\) minimizes \(E(X - Z)^2\) over \(\mathcal G\)-measurable \(Z\), and that it is unique a.s.
Solution
- Assume X ∈ L²; let Y = E[X | 𝒢] and Z ∈ L²(𝒢).
- E(X − Z)² = E(X − Y)² + 2E[(X − Y)(Y − Z)] + E(Y − Z)².
- Y − Z is 𝒢-measurable, so E[(X − Y)(Y − Z)] = E[(Y − Z) E(X − Y | 𝒢)] = 0.
- Hence E(X − Z)² = E(X − Y)² + E(Y − Z)² ≥ E(X − Y)². Equality holds iff Z = Y almost surely, which gives uniqueness.
-
The expected length of a fair game. For a fair \(\pm 1\) walk from \(a\), stopped at \(0\) or \(b\), derive \(E\tau = a(b - a)\) from \(S_n^2 - n\).
Solution
- S_n² − n is a martingale for a ±1 walk.
- τ, the exit time from (0, b) started at a, has E τ < ∞ (a geometric bound: from anywhere, b straight steps exit), and the stopped process is dominated by b² + τ.
- So optional stopping gives E S_τ² − E τ = S₀² = a².
- E S_τ² = b² · P(hit b) = b² · a/b = ab, so E τ = ab − a² = a(b − a).
-
De Moivre's martingale. Show that \((q/p)^{S_n}\) is a martingale for a \(p\)-coin walk, and derive the probability of reaching \(b\).
Solution
- E[(q/p)^{S_{n+1}} | ℱ_n] = (q/p)^{S_n} [p (q/p) + q (p/q)] = (q/p)^{S_n} (q + p) = (q/p)^{S_n}.
- Stopping at 0 or b (bounded paths) gives (q/p)^a = P_b (q/p)^b + (1 − P_b).
- So P(reach b) = (1 − (q/p)^a) / (1 − (q/p)^b). For roulette (p = 18/38), a = 10 and b = 20, this is 0.259.
-
A two-state chain. For a two-state chain with \(P(1 \mid 1) = a\), \(P(1 \mid 0) = b\), find \(\pi_1\) and the lag-\(k\) autocorrelation \((a - b)^k\).
Solution
- Balance: π₁(1 − a) = π₀ b, so π₁ = b / (1 − a + b).
- The second eigenvalue of P is a − b, so E[X_k | X₀] − π₁ = (a − b)^k (X₀ − π₁) (true at k = 1 by direct check, then by the Markov property).
- So under stationary initialization, Cov(X₀, X_k) = (a − b)^k Var X₀ and the lag-k correlation is (a − b)^k.
- For Onegin, a = 0.128 and b = 0.663: π₁ = 0.663 / 1.535 = 0.432 and the lag-1 correlation is −0.534.
-
McDiarmid for empty bins. Use McDiarmid to show that the empty-bin count \(Z\) satisfies \(P(|Z - EZ| \ge t) \le 2e^{-2t^2/n}\).
Solution
- Z = f(X₁, …, X_n), where X_i is ball i's bin, independent.
- Moving one ball can empty at most one bin and fill at most one, so Z changes by at most 1: c_i = 1.
- McDiarmid: P(|Z − EZ| ≥ t) ≤ 2 exp(−2t² / Σ c_i²) = 2 exp(−2t²/n).
- For n = 1,000 the bound is below 0.05 only for t ≥ 43, but the simulated SD is 9.9: valid but loose.
-
The Nelson–Aalen variance. Derive the Nelson–Aalen bracket and its estimator \(\sum d_j/Y_j^2\); distinguish them.
Solution
- Ĥ(t) − H*(t) = ∫₀ᵗ J(s)/Y(s) dM(s), where J = 1(Y > 0), H*(t) = ∫₀ᵗJ(s)λ(s)ds, and M = N − ∫Yλ. Assume a nonexplosive continuous-time intensity model with no simultaneous individual events and sufficient integrability.
- The integrand is predictable, so the integral is a martingale with predictable variation ∫ J/Y² d⟨M⟩ = ∫ J/Y² · Y λ ds = ∫ J λ / Y ds.
- Replacing the compensator increment Yλ ds by dN gives ∫J/Y² dN = Σ d_j/Y_j², an observed-event bracket estimator. With individual unit jumps it is the optional variation. Aggregated simultaneous jumps have squared jump sizes instead; ties in recorded times need a grouping convention, and the log-rank variance uses its tied-event finite-population correction.
Notes and sources
Where it comes back
- Part 45: Rao–Blackwell as a conditional expectation; sufficiency as a σ-algebra; Brown's link between admissibility and the recurrence of Brownian motion (chapter 9's Pólya).
- Part 47: the score is a martingale: the asymptotics of the MLE, along dependent sequences too.
- Part 48: empirical processes: Donsker for whole classes of functions; the Brownian bridge behind Kolmogorov–Smirnov.
- Part 53: posterior consistency, beyond Doob's theorem.
- Part 54: McDiarmid for the generalization gap of learned predictors.
- Part 58: Ville's inequality at work: e-values, confidence sequences, bandits and Freedman's inequality.
Glossary
- Conditioning.
- Conditional expectation; the tower property; Radon–Nikodym derivative; L² projection; Borel's paradox: what you know.
- Filtration; adapted, predictable; stopping time; stopped process: information in time.
- Martingales.
- Martingale, sub- and supermartingale; Doob decomposition; compensator; predictable and optional variation: fair games.
- Optional stopping; gambler's ruin; de Moivre's martingale; Wald's identities: when to quit.
- Doob's maximal inequality; Ville's inequality; e-value; anytime-valid test: how high a game climbs.
- Upcrossings; martingale convergence; uniform integrability; Lévy's upward theorem; reverse martingale: limits.
- Azuma–Hoeffding; McDiarmid; Freedman; Doob martingale: concentration.
- Martingale CLT; conditional Lindeberg condition; unit root: normal limits.
- Markov chains.
- Transition kernel; stationary law; reversibility; Harris chain; small set; minorization; drift (Foster–Lyapunov); geometric ergodicity; asymptotic variance; batch means: MCMC theory.
- Total variation; coupling; mixing time; spectral gap; relaxation time; cutoff; recurrence and transience: forgetting the start.
- Continuous time.
- Brownian motion; Wiener measure; Schauder functions; scaling; quadratic variation; reflection principle; Brownian bridge: the continuous random walk.
- Invariance principle; Donsker's theorem; Dickey–Fuller law; law of the iterated logarithm; Strassen's law: the walk from far away.
- Counting process; intensity; Doob–Meyer decomposition; Nelson–Aalen; Rebolledo's CLT: survival underneath.
Sources
- Markov and the dependent law of large numbers.
- A. A. Markov, Izv. Fiz.-Mat. Obshch. Kazan 15 (1906); Bull. Acad. Imp. Sci. St.-Pétersbourg 7 (1913), transl. Science in Context 19 (2006).
- B. Hayes, "First links in the Markov chain", American Scientist 101 (2013).
- Conditional expectation and martingales.
- A. N. Kolmogorov (1933); É. Borel, Éléments de la théorie des probabilités (1909).
- J. Ville, Étude critique de la notion de collectif (1939); J. L. Doob, Stochastic Processes (1953).
- G. Pólya, Math. Ann. 84 (1921); F. Eggenberger & G. Pólya, Z. Angew. Math. Mech. 3 (1923).
- Concentration and the martingale CLT.
- K. Azuma, Tôhoku Math. J. 19 (1967); W. Hoeffding, JASA 58 (1963); C. McDiarmid, Surveys in Combinatorics (1989).
- D. Freedman, Ann. Probab. 3 (1975); D. McLeish, Ann. Probab. 2 (1974); P. Hall & C. Heyde, Martingale Limit Theory and Its Application (1980).
- H. B. Mann & A. Wald, Econometrica 11 (1943); D. Dickey & W. Fuller, JASA 74 (1979).
- Markov chains and mixing.
- S. Meyn & R. Tweedie, Markov Chains and Stochastic Stability (2nd ed. 2009); K. Mengersen & R. Tweedie, Ann. Stat. 24 (1996).
- G. Roberts & J. Rosenthal, Probab. Surveys 1 (2004); C. Geyer, Stat. Sci. 7 (1992).
- D. Bayer & P. Diaconis, Ann. Appl. Probab. 2 (1992); D. Levin, Y. Peres & E. Wilmer, Markov Chains and Mixing Times (2nd ed. 2017).
- Brownian motion and Donsker.
- N. Wiener, J. Math. Phys. 2 (1923); R. Paley, N. Wiener & A. Zygmund, Math. Z. 37 (1933); P. Lévy (1948); Z. Ciesielski, Studia Math. 20 (1961).
- M. Donsker, Mem. AMS 6 (1951); A. Khinchin, Fund. Math. 6 (1924); V. Strassen, Z. Wahrsch. 3 (1964).
- Counting processes.
- O. Aalen, Ann. Stat. 6 (1978); R. Rebolledo, Z. Wahrsch. 51 (1980).
- P. K. Andersen, Ø. Borgan, R. Gill & N. Keiding, Statistical Models Based on Counting Processes (1993).
- E. Freireich et al., Blood 21 (1963); E. Gehan, Biometrika 52 (1965).
- Books. D. Williams, Probability with Martingales (1991); R. Durrett, Probability: Theory and Examples (5th ed. 2019).
About this partfrom its README
Part 44 of a sixty-five-part course in statistics, from a first course to a PhD (see the series plan and the syllabus), and the second part of Stage IV, the PhD core. In 1913 Andrei Markov counted the vowels and consonants in the first 20,000 letters of Pushkin's Eugene Onegin to show that the law of large numbers does not need independence. This part builds the theory of randomness that unfolds in time:
- conditional expectation, martingales, optional stopping, Ville's inequality and martingale convergence;
- concentration (Azuma, McDiarmid, Freedman) and the martingale CLT;
- Markov chains on general spaces, with drift, minorization, coupling and mixing times;
- Brownian motion, Donsker's invariance principle, the law of the iterated logarithm, and counting processes.
It keeps promises from earlier parts:
- Part 17 used AR(1) and the unit root; chapter 7 gives the martingale CLT behind the first and chapter 11 the Dickey–Fuller law behind the second.
- Part 27 used MCMC standard errors and R-hat; chapters 8 and 9 prove when a chain's average obeys a CLT.
- Part 40 used Greenwood's formula and the log-rank test; chapter 13 shows the martingales underneath.
- Part 43 warned that Kolmogorov's extension theorem cannot see continuity; chapter 10 builds Brownian motion directly.
Built in this part:
statkit.chains(explainer/stats/kit/chains.py), tested intests/test_stats_kit_chains.py:- Markov's chain: the two-state fit with stationary law and lag-1 correlation; the variance of block counts under a chain.
- Mixing: total variation; stationary laws; the lazy walk on a cycle and on the hypercube (exactly, by Hamming weight); distance-to-stationarity curves and mixing times; spectral gaps; the coupling time on the cycle; the Bayer–Diaconis exact total variation of riffle shuffles, by Eulerian numbers.
- Martingales and walks: Pólya's return probabilities; gambler's ruin and its expected duration; betting (likelihood-ratio) paths; the Azuma and McDiarmid bounds; Pólya's urn.
- Brownian motion: Schauder functions and the Lévy–Ciesielski construction; quadratic and total variation; the Dickey–Fuller law by simulation; the LIL envelope.
- MCMC and AR(1): batch-means standard errors; AR(1) least squares with an intercept; a random-walk Metropolis chain on N(0, 1).
- The betting paths (
BettingPathsinexplainer/stats/viz.py), the part's instrument: a fan of likelihood-ratio (wealth) paths on a log scale, with Ville's threshold 1/α drawn in and the paths that cross it lit up.
Data.
- From the Museum:
- Pushkin's Eugene Onegin: the first 20,000 Cyrillic letters, as vowels and consonants
(
explainer/stats/data/onegin_vc.txt, rebuilt from the text on lib.ru). It gives 8,639 vowels, 1,109 vowel–vowel and 3,831 consonant–consonant pairs, against Markov's 8,638, 1,104 and 3,827 (his table is inmuseum.MARKOV_1913). - The 6-MP trial's placebo arm (Freireich et al. 1963, via Gehan 1965).
- Pushkin's Eugene Onegin: the first 20,000 Cyrillic letters, as vowels and consonants
(
- The rest is exact arithmetic or seeded simulation.
The Coverage Board gains six rows:
| Method | Setting | Achieved | Verdict |
|---|---|---|---|
| AR(1) least squares, 90% interval for φ | φ = 0.5, n = 200 | 89.7% | kept |
| AR(1) least squares, 90% interval for φ | φ = 0.98, n = 100 | 70.5% | broken (near a unit root) |
| MCMC mean, batch-means SE, 90% | RWM on N(0, 1), 20,000 steps | 90.5% | kept |
| MCMC mean, i.i.d. SE, 90% | RWM on N(0, 1), 20,000 steps | 27.3% | broken |
| betting test, reject at wealth 10 (size 10%) | a fair coin watched for 1,000 tosses | 8.9% false alarms | kept |
| z test at every 10th toss (size 10%) | a fair coin watched for 1,000 tosses | 59.9% false alarms | broken |
Chapter notes
| # | Chapter | Numbers |
|---|---|---|
| 0 | Markov counts the vowels of Onegin | P(V | V) = 0.128, P(V | C) = 0.663; π = 0.432; block variance 5.25 vs 24.5 (i.i.d.) and 7.56 (chain) |
| 1 | Conditional expectation | Borel's paradox: 6,460 wedge points vs 10,065 geodesic-band points approaching the same half-meridian |
| 2 | Martingales | likelihood ratios: median wealth 1.4 × 10⁻⁹ after 1,000 tosses, theoretical mean 1 (Monte Carlo 0.98 at 20 tosses); finite-urn calibrated KS p = 0.7421 |
| 3 | Optional stopping | roulette 10 → 20: 0.259; 50 → 100: 0.0051; 100 → 200: 2.7 × 10⁻⁵; doubling: ruin 0.0016, EV −0.67 |
| 4 | Maximal inequalities and Ville | 8.2% of 4,000 null paths ever reach wealth 10 (≤ 10%) |
| 5 | Martingale convergence | upcrossings; Pólya's urn settles; reverse martingales and the strong law |
| 6 | Martingale concentration | empty bins: mean 367.7, SD 9.9; McDiarmid scale proxy ≈ 16, not the actual SD |
| 7 | The martingale CLT | AR(1): φ = 0.5 covered 89.9%, skew −0.22; φ = 0.98 covered 70.0%, skew −1.25 |
| 8 | Markov chains on general spaces | RWM: τ = 23; SE 0.0022 (i.i.d.) vs 0.0104 (batch means) |
| 9 | Coupling and mixing | cycle n = 20: t_mix 38, relaxation 40.9; hypercube t_mix 16 (d = 10), 91 (d = 40); 7 shuffles: TV 0.334 |
| 10 | Brownian motion | Σ(ΔB)² = 0.911 at 1,024 pieces, 0.992 at 65,536; Σ|ΔB| = 24.5 → 203.7 |
| 11 | Donsker's invariance principle | reflection 0.311 vs 0.317; Dickey–Fuller 5% point −1.95; 68% of t's negative |
| 12 | The law of the iterated logarithm | ratios of the running maximum to √(2n log log n): 0.76–1.27 |
| 13 | Counting processes | 200 lifetimes, 118 events; 6-MP placebo Nelson–Aalen 3.53 (SE 1.25) at 23 weeks |
| 14 | Outro | — |
The rest of the part's numbers, chapter by chapter:
- Hook. Markov's fitted chain has lag-1 correlation −0.53: vowels avoid vowels. The variance of the vowel count in 200 blocks of 100 letters is 5.25, a fifth of the i.i.d. 24.5 and close to the chain's 7.56. Markov reported dispersion ratios of 0.208 and about 0.3; the rebuilt text gives 0.214 and 0.308.
- Chapter 1.
- E[X | 𝒢] is defined by Radon–Nikodym (Kolmogorov 1933) and, in L², is the orthogonal projection onto 𝒢-measurable variables: the best predictor.
- The tower property, taking out what is known, and the conditional variance decomposition.
- Borel's paradox: the same half-meridian {y = 0, x > 0}, with angle φ = atan2(z, x), is approached by a longitude wedge or a geodesic band. Their limiting angle densities are cos(φ)/2 and 1/π on (−π/2, π/2). The limiting set alone does not specify a conditional law. A regular conditional law is only unique almost everywhere in the conditioning value.
- Chapter 2.
- Martingales, sub- and supermartingales; the Doob decomposition into a martingale and a predictable compensator.
- Under the null, a likelihood ratio is a martingale with mean one, yet almost every path goes to zero (KL 0.0204 per toss): the mean is carried by rare large paths.
- Pólya's urn: its bounded share martingale has a Beta(1,1) limit. The figure uses 24 long paths and 2,000 independent urns at 600 draws. At that finite horizon the 601 possible shares are exactly uniform on a lattice. The KS distance is 0.0146847, calibrated against that law with 9,999 multinomial null runs: p = 0.7421 (Monte Carlo SE 0.00438), not evidence proving a limit theorem.
- Chapter 3.
- Optional stopping holds for bounded stopping times; for uniformly integrable stopped martingales at an almost surely finite time; or for uniformly bounded increments with E τ < ∞. Integrable increments alone are insufficient.
- Fair ruin: P(reach b) = a/b and E τ = a(b − a): 100, 2,500 and 10,000 spins.
- Unfair ruin by de Moivre's martingale (q/p)^S.
- Doubling with a 1,023-unit bank and 10 losing bets (1 through 512): ruin probability 0.0016 at roulette odds, EV −0.67. Without a bank limit, the needed credit has median 1 but maximum 1,048,575 in 200,000 independent strategy cycles.
- Chapter 4.
- Doob's maximal inequality and Doob's L² inequality.
- Ville (1939): for a nonnegative martingale with mean one, P(sup M ≥ 1/α) ≤ α. This gives anytime-valid tests: the betting paths stay valid under continuous monitoring.
- E-values and p-values: 1/max₀≤k≤n M_k is an anytime-valid p-value including M₀ = 1; a current reciprocal must be capped at 1. Products require independent or conditionally valid factors. Continuing the same valid process differs from selecting a new bet after observing its result.
- Chapter 5. The upcrossing inequality gives convergence of L¹-bounded martingales almost surely; uniform integrability gives L¹ convergence. Lévy's upward theorem uses the sigma-algebra generated by all finite information sets. Reverse-martingale convergence proves the iid integrable strong law. De Finetti additionally needs conditional factorization of all bounded indicator products, outlined here.
- Chapter 6.
- Azuma–Hoeffding for bounded differences.
- McDiarmid's bounded-difference inequality, with constant 2 from Hoeffding's lemma on a known range.
- Freedman's Bernstein-type inequality, which uses the predictable variation.
- Chapter 7.
- McLeish's martingale CLT: conditional variances converge in probability and a conditional Lindeberg condition holds.
- For the AR(1) score Σ x_{t−1}ε_t it gives √n(φ̂ − φ) ⇒ N(0, 1 − φ²). For every fixed |φ| < 1 it remains valid under the stationary moment assumptions. At φ = 0.98 and n = 100 the approximation is poor; a unit root or local-to-unity sequence changes the normalization and limit.
- Chapter 8.
- Harris chains; small sets and minorization; Foster–Lyapunov drift conditions.
- With psi-irreducibility, aperiodicity, the small-set drift/minorization conditions and Eπ|f|^(2+δ) < ∞, the MCMC CLT has variance σ²τ. The displayed τ is a positive-lag truncation at 60, and the 30-batch SE is a finite approximation. Consistency of batch means needs both batch length and number to grow.
- Mengersen–Tweedie: random-walk Metropolis is geometrically ergodic only for light-tailed targets.
- Chapter 9.
- Total variation; the coupling inequality.
- The lazy cycle of 20 mixes in about n² steps; the hypercube in about (d/2) log d.
- The spectral gap bounds the relaxation time.
- Bayer–Diaconis: the riffle-shuffle distances fall off a cliff near (3/2) log₂ 52; after 7 shuffles TV = 0.334.
- Pólya's recurrence: returns within 10⁴ steps 0.987 in 1D, 0.713 in 2D, 0.327 in 3D (limit 0.3405).
- Chapter 10.
- Lévy–Ciesielski: Schauder tents built on Haar wavelets converge uniformly.
- Scaling; nowhere differentiability (Paley–Wiener–Zygmund 1933); three martingales.
- Exit problems: P = b/(a + b), E τ = ab.
- Quadratic variation 1, total variation infinite.
- Chapter 11.
- Donsker (1951): centered iid walks with finite positive variance, standardized by σ√n, converge as step paths in D[0,1] with J₁ topology, or as linearly interpolated paths in C[0,1]. Functionals must be continuous at almost every Brownian path.
- The reflection principle: P(max ≥ 1) = 2P(B₁ ≥ 1) = 0.317, simulated 0.311.
- The Brownian bridge and Kolmogorov–Smirnov (to Part 48).
- The Dickey–Fuller statistic converges to a functional of Brownian motion: with neither an intercept nor a trend its 5% point is about −1.95 (ρ form −8.06), versus −1.645 for a standard normal. Adding an intercept gives about −2.86. The derivation also needs Σ ε²/n → σ² by the LLN; Donsker alone does not give the stochastic-integral limit.
- Chapter 12.
- Khinchin (1924): limsup S_n/√(2n log log n) = 1 almost surely.
- Strassen's functional law; the proof by exponential maximal bounds and Borel–Cantelli on geometric blocks.
- For sample-mean-centered intervals with a root-n asymptotic boundary, all-time coverage requires an iterated-logarithm factor; this is not a universal claim about every test or interval shape. The plotted finite-window maxima do not converge to 1 as the endpoint increases with a fixed initial cutoff.
- Chapter 13.
- N − Λ is a martingale with predictable variation Λ (Aalen 1978), the Doob–Meyer decomposition.
- Nelson–Aalen targets H*(t) = ∫₀ᵗ1{Y(s)>0}λ(s)ds. Its predictable bracket uses the true hazard; Σ d/Y² estimates that bracket. Recorded-week ties use the grouped-event convention.
- The log-rank statistic is a martingale integral.
- Rebolledo's CLT requires a deterministic continuous bracket limit and Lindeberg/small-jump control. It supports normalized KM/NA estimators, log-rank scores and regular Cox coefficient estimates under independent censoring, predictable entry, adequate risk sets and their other regularity conditions.
Companion material in this repository
The syllabus's plan for this partfrom SYLLABUS.md, the plan of record
- Hook: Markov (1913). Eugene Onegin's 20,000 letters, recomputed on the original Russian.
- Conditional expectation. Via Radon–Nikodym and as an L² projection; regular conditional distributions and disintegration.
- Martingales. Doob decomposition; likelihood ratios under the null; Doob martingales.
- Optional stopping. The theorem and its conditions; gambler's ruin; why doubling fails.
- Maximal inequalities. Doob's Lᵖ; Ville's inequality (1939) (
BettingPaths). - Convergence. Upcrossings; uniform integrability; reverse martingales; the SLLN and de Finetti (Part 5) by reverse martingales.
- Martingale concentration. Azuma–Hoeffding; McDiarmid; Freedman.
- The martingale CLT (Hall & Heyde 1980; McLeish 1974).
- Markov chains on general spaces. Harris recurrence; drift and minorization (Meyn & Tweedie); geometric ergodicity; the MCMC CLT that justifies Part 27's standard errors.
- Coupling and mixing. Doeblin; total variation; spectral gaps; Pólya's recurrence (1921).
- Brownian motion. Lévy–Ciesielski construction; continuity and nowhere-differentiability; quadratic variation (cross-reference Stochastic Calculus, Visualized).
- Donsker's invariance principle, via Skorokhod embedding; the Dickey–Fuller limit (Part 38) explained.
- The LIL (Khinchin 1924; Hartman–Wintner 1941).
- Counting processes. Compensators; Aalen's martingales; Rebolledo's CLT (the survival theory of Part 40).
- Outro.
Built: a coupling and mixing lab. Books: Williams; Durrett; Meyn & Tweedie; Levin, Peres & Wilmer; Hall & Heyde.
Build the film
python -m videos.stats.stats44.compute # the part's numbers, into .cache/stats44
python tools/build.py stats44 # render and assemble the film
EXPLAINER_TTS=silent python tools/qa_scene.py stats44 Hook # one chapter, silent, with a contact sheet
Scenes: videos/stats/stats44. Setup: see the course page. Source of these notes: the README and the scenes' narration.
Build it
OMP_NUM_THREADS=1 python -m videos.stats.stats44.compute # once (a few minutes)
python tools/build.py stats44 -q l # fast 480p preview
python tools/build.py stats44 # 1080p30 -> renders/stats44.mp4
python tools/qa_scene.py stats44 Maximal
python tools/lecture_length.py stats44 --floor 50