SStatistics, Built

Stage IV · PhD Core

Part 53 of 65

Bayesian Asymptotics and Nonparametric Bayes

PhDstarts at this level54 min of film13 chaptersprerequisites: Part 26, Part 47, Part 50

When does the posterior find the truth, and are its credible sets honest?

The part opens with Diaconis and Freedman (1986): in a symmetric location problem a reasonable prior, a symmetrized Dirichlet process with a Cauchy base, has a posterior that never settles at the true centre. Doob's theorem is proved by martingales and shown to promise consistency only for truths the prior itself would draw; Schwartz's theorem replaces it with Kullback-Leibler support plus tests. Contraction rates (Ghosal, Ghosh and van der Vaart) are made exact in the Gaussian sequence model, where a prior of smoothness alpha meets a truth of smoothness beta. Bernstein-von Mises follows from Part 47's LAN, and then fails in infinite dimensions: with an oversmoothing prior the credible ball's coverage falls from 100% to about zero. The part builds the nonparametric priors themselves, Dirichlet processes with the Chinese restaurant and a mixture fitted to Old Faithful, Polya trees, and Gaussian processes through small-ball probabilities, and shows empirical Bayes adapting to the smoothness. It ends on the Board with three honest answers: adaptive credible sets cover polished-tail truths and not all truths, spike-and-slab and horseshoe intervals undercover intermediate signals, and a tempered posterior repairs a Poisson interval that covers 62% on overdispersed counts.

What you need. Part 26's Bayesian modelling, Part 47's LAN, Part 50's minimax rates and sequence model, and martingale convergence from Part 44.

Hook
Diaconis & Freedman's inconsistency, 1986
Mathematics
Doob and Schwartz, contraction rates, parametric and semiparametric BvM, DP and GP priors, credible-band coverage, spike-and-slab and horseshoe theory, Gibbs posteriors
Built
statkit.bnp

What you will be able to do

Bachelor's

  • Explain what it means for a posterior to be consistent, and what Diaconis and Freedman's example shows a reasonable prior can do.

Master's

  • Compute the posterior, its exact risk and its credible ball in the Gaussian sequence model, and read the contraction rate off the prior's and the truth's smoothness.
  • Simulate a Dirichlet process by the Polya urn and by stick-breaking, and compute its posterior given data.

PhD

  • Prove Doob's theorem and state Schwartz's theorem and the prior-mass, entropy and sieve conditions of the contraction-rate theorem.
  • Prove the parametric Bernstein-von Mises theorem from LAN and explain why it fails for infinite-dimensional parameters but can hold for smooth functionals.
  • State why no credible set can be both adaptive and honest over all truths, and what the polished-tail condition restores.

Practice

  • Check the frequentist coverage of a credible interval by simulation before reporting it, for sparse signals of intermediate size in particular.
  • Detect an overdispersed count model's overconfident posterior and calibrate a tempered posterior's learning rate.

Contents

Each chapter has a home level. Choose a track to see what to read and watch: Bachelor's 6 min · Master's 10 min · PhD 54 min · Practice 10 min.

  1. 0Diaconis and Freedman, 1986Bachelor's3 min
  2. 1Doob's theoremPhD4 min
  3. 2Schwartz's theoremPhD4 min
  4. 3Contraction ratesPhD5 min
  5. 4Bernstein-von MisesPhD4 min
  6. 5Semiparametric BvM and its failuresPhD5 min
  7. 6Dirichlet processes and Polya treesPhD6 min
  8. 7Gaussian process priorsPhD4 min
  9. 8AdaptationPhD4 min
  10. 9Credible sets that coverPhD3 min
  11. 10High-dimensional BayesPhD5 min
  12. 11Misspecification and generalized posteriorsPractice4 min
  13. Recap, problems, and the road aheadAll tracks2 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.

Diaconis and Freedman, 1986Bachelor's3 min

In 1986, Persi Diaconis and David Freedman published a paper on inconsistent Bayes estimates of location that unsettled a generation of Bayesians. The problem could hardly be simpler: estimate the centre of a symmetric distribution. Their Bayesian was reasonable: a smooth prior on the centre, and a Dirichlet-process prior, the standard nonparametric choice, on the shape of the distribution, symmetrized about the centre. The data came from a perfectly well-behaved symmetric distribution, centred at zero. And as the data grew, the posterior for the centre did not settle at zero. Their constructed model shows that increasing the sample size need not force posterior concentration at the true centre.

The model: observations equal a centre plus symmetric noise. The prior: a smooth density for the centre, and for the noise distribution, Thomas Ferguson's Dirichlet process of 1973, symmetrized, with a Cauchy base measure. The truth: centre zero, and a smooth symmetric noise density, which they constructed, within the class used for their counterexample. The posterior need not concentrate at the true centre. That is a statement about posterior mass, not about every possible point estimate: a symmetric two-mode distribution can have its mean exactly at zero.

How could this happen? Joseph Doob had proved in 1949 that a Bayesian is consistent for almost every truth, almost every in the sense of the prior itself. David Freedman had shown in 1963 that the exceptional set, though of prior probability zero, can be large in another sense: in specific infinite-dimensional model and prior spaces, genericity results can make inconsistency topologically large. This is not a statement about every prior in every infinite-dimensional model. Diaconis and Freedman's example made it concrete, with a prior people actually used, on a truth nobody would call strange. The moral: with infinitely many parameters, the prior does not wash out on its own. Which priors do, at what rate, and whether their credible sets can be trusted, is the subject of this part.

The questions, then. When does a posterior concentrate at the truth, Doob's and Schwartz's question? How fast, the question of Ghosal, Ghosh and van der Vaart? When does the posterior look like a normal distribution centred at an efficient estimator, the Bernstein–von Mises question? And the one practitioners care about most: when is a ninety-five percent credible set also a ninety-five percent confidence set?

Three promises come due. Part twenty-six said the prior washes out as data accumulate, for models with finitely many parameters; chapters one to five ask when it does in general. Part forty-seven built local asymptotic normality for frequentist estimators; chapter four uses it to prove the Bernstein–von Mises theorem. And Part fifty found minimax rates; chapters three and seven to ten ask whether Bayesian posteriors contract at those rates, and adapt to unknown smoothness.

Numbers: the symmetrized DP location model

1Doob's theoremPhD4 min

Doob's theorem: consistency, almost surely under the prior. Joseph Doob's theorem of 1949 requires identifiable i.i.d. sampling, measurable parametrization and suitable standard-Borel parameter and sample spaces: a parameter drawn from the prior, observations independent given it, and an identifiable model. Then, for almost every value of the parameter, the posterior converges to a point mass at that value. Within those measurability and identifiability conditions, no extra smoothness or finite-dimensional restriction is needed. The catch is in the words almost every. They are measured by the prior itself. The theorem says the Bayesian expects to be consistent, which is not the same as being consistent for the truth that actually generated the data.

The proof is pure Part forty-four. For any bounded function of the parameter, its posterior mean is a bounded martingale in n. By the martingale convergence theorem it converges almost surely, to the conditional expectation given the whole infinite sample. But the infinite sample identifies the parameter: the empirical distribution converges to P theta, which determines theta. So that conditional expectation is just the function evaluated at the parameter, for each fixed bounded measurable function its posterior expectation converges almost surely under the joint law. A countable determining class supplies a common event for weak posterior consistency. All of this holds under the joint law of the parameter and the data, which is why the exceptional set is null under the prior.

Doob's theorem in a picture. Draw a coin's probability from a uniform prior, then flip it. Twenty-four such truths. The posterior means, under the same uniform prior, wander at first and then settle. Each one settles on its own truth, the white dots on the right: the average error after three thousand flips is . When the truth is drawn from the prior, Bayes is consistent. In one dimension, with a prior that puts mass everywhere, that illustrates regular interior Bernoulli truths; Doob alone still gives only a prior-almost-everywhere assertion; in infinite dimensions it need not.

The finite case shows the mechanism. A prior on three coin probabilities, point three, point four and point five, with the truth at point four. The posterior probability of the truth, in green, climbs towards one. Each wrong value's posterior falls like e to the minus n times its Kullback–Leibler divergence from the truth, for point three, because the log likelihood ratio is an average that the law of large numbers controls. After eight hundred flips the truth has posterior probability . With finitely many candidates, consistency is just the law of large numbers; the trouble starts with infinitely many.

So why is Doob's theorem not the end of the story? Because a set of prior probability zero can be most of the parameter space in other senses. David Freedman showed in 1963 that for priors on distributions over the integers, genericity results can make consistency topologically small in specified spaces of priors and truths. They do not say every prior is inconsistent for most truths under every topology. And the frequentist's truth is fixed by nature, not drawn from anyone's prior. What is needed is a theorem that says which truths a given prior can learn. That is Lorraine Schwartz's.

Numbers: 24 truths from a uniform prior: mean error 0.008 after 3,000 flips; a three-point prior: the truth's posterior → 1

2Schwartz's theoremPhD4 min

Schwartz's theorem: which truths can a prior learn? Lorraine Schwartz's theorem of 1965 is about a fixed truth p zero. The first condition: the prior puts positive mass on every Kullback–Leibler neighbourhood of the truth, however small. In an i.i.d. dominated model, a sufficient testing condition is: for each chosen neighbourhood U of the truth, there are tests that distinguish the truth from everything outside U, with errors that vanish exponentially fast. Then the posterior mass of U tends to one, almost surely under the truth. Two ingredients, then: enough prior mass near the truth, and a model in which the truth can be told apart from the alternatives. Every consistency and rate theorem since is built from these two.

Why it works. Write the posterior mass outside U as a ratio of integrals of likelihood ratios against the truth. The denominator cannot be too small: the prior has mass near the truth, where the likelihood ratio decays at most like e to the minus n epsilon, by the law of large numbers applied to the log ratio. Multiply the numerator by one minus the test. Uniform type-two error controls the expectation of this test-weighted integral; small type-one error controls the event where the test rejects. The raw numerator need not itself have exponentially small expectation. Choose epsilon below c and the ratio vanishes exponentially.

The simplest illustration. Normal observations with true mean zero, at ten, a hundred and a thousand observations. With a wide normal prior, which puts mass in every neighbourhood of zero, the posteriors in blue concentrate at zero. Now a second prior, uniform on one to three, which excludes the truth. Its posteriors, in red, pile up against the boundary at one, the point of the support closest to the truth in Kullback–Leibler divergence, with posterior mean at a thousand observations. They become ever more confident in the wrong answer. Schwartz's first condition is not a technicality.

For densities, tests against everything outside a neighbourhood can be hard to build directly. Andrew Barron, Mark Schervish and Larry Wasserman's way around it, in 1999, splits the model into a sieve and the rest. On the sieve, the covering numbers must grow at most exponentially in n, slowly enough that tests exist, by the entropy arguments of Part forty-eight. Off it, the prior's mass must be exponentially small, so the posterior can ignore it. Then the posterior is consistent in Hellinger distance. The same split, made quantitative, is the next chapter's theorem.

Where the conditions come from in practice. Kullback–Leibler support holds for Dirichlet-process mixtures of normals at most smooth densities, as Subhashis Ghosal, Jayanta Ghosh and R. V. Ramamoorthi showed in 1999. Tests exist when the model is not too large, measured by the entropy of Part forty-eight. And A Dirichlet process draws discrete distributions, so a continuous truth is not in its KL support as a prior directly on sampling distributions. KL support is sufficient, not necessary for every mode of consistency: DP posterior CDFs can still be weakly consistent. The location counterexample needs its own model-specific argument. Next, the same two ingredients, quantified, give rates.

Numbers: N(0, 1) data, a Uniform[1, 3] prior: posterior mean 1.114 (n = 10), 1.010 (100), 1.001 (1,000)

3Contraction ratesPhD5 min

Contraction rates: prior mass, entropy and tests, quantified. Subhashis Ghosal, Jayanta Ghosh and Aad van der Vaart made Schwartz's theorem quantitative in 2000. The first condition: the prior puts mass at least e to the minus c n epsilon squared on a neighbourhood controlling both KL divergence and the second log-likelihood-ratio moment by epsilon n squared. The second: most of the prior's mass sits on a sieve whose covering number at scale epsilon n has logarithm at most n epsilon n squared, which guarantees tests by Le Cam's and Birgé's constructions. For the theorem's testable metric and sieves, with n epsilon n squared growing, the posterior contracts in probability at rate epsilon n for a sufficiently large constant: its mass outside a ball of radius a constant times epsilon n vanishes. The rate solves a balance: n epsilon squared is the logarithm of the size of the space the prior must search, as for the minimax rates of Part fifty.

A laboratory where everything is exact: Part fifty's Gaussian sequence model, with a truth of smoothness beta. Give the coefficients independent normal priors with variances k to the minus one minus two alpha: a Gaussian sequence prior whose paths lie in Sobolev spaces of every order below alpha, typically not alpha itself. The posterior is conjugate, normal, coordinate by coordinate, and its risk can be computed exactly. Its contraction rate is n to the minus the smaller of alpha and beta, over one plus two alpha, as Bartek Knapik, Aad van der Vaart and Harry van Zanten found in 2011: minimax exactly when the prior's smoothness matches the truth's.

The exact finite-coordinate root mean squared errors of the posterior mean for a boundary hyperrectangle-regular truth of order one, from a hundred to a million observations. With a prior of the same smoothness, in green, the slope is , the minimax minus a third. A rougher prior, smoothness a half, undersmooths: slope , against the theory's minus a quarter. A smoother prior, smoothness two, oversmooths and is slower still, , against minus a fifth. Both mistakes cost a polynomial factor in the rate, which is why chapter eight lets the data choose alpha.

What contraction looks like, with this part's instrument, the contraction ball. Two coordinates of the parameter, posterior draws in blue, an exact projected bivariate Gaussian ninety-five percent credible ellipse in gold, and the truth in white. At a hundred, a thousand and ten thousand observations, the cloud shrinks around the truth, and the ellipse contains it in this seeded example. This is not a proof of repeated-sampling coverage. In the low coordinates the posterior behaves like a parametric one; the interesting failures happen in the high ones, where prior and data compete.

The two conditions are a bias–variance trade-off in disguise. The prior-mass condition asks how probable a small ball around the truth is under the prior. The entropy condition asks how complex the region holding the prior's mass is. A prior that is too rough spreads its mass over a space of large entropy, a variance-like cost. A prior that is too smooth puts little mass near a rough truth, a bias-like cost. The best rate balances them, and chapter seven computes both for Gaussian processes.

The theorem has been applied to almost every nonparametric prior. Subhashis Ghosal and Aad van der Vaart showed in 2001 that Dirichlet-process mixtures of normals estimate very smooth densities at nearly the parametric rate, one over root n up to logarithms. With a prior on the scale too, Weining Shen, Surya Tokdar and Ghosal showed in 2013 that they attain appropriate near-minimax rates, with logarithmic factors and smoothness, tail and prior restrictions stated in their theorem. Random histograms can adapt over their supported smoothness ranges; ordinary piecewise-constant histograms do not exploit arbitrary high smoothness. And suitable sparse priors attain squared Euclidean contraction radius of order s log of p over s, over n in the normalized regression model, as chapter ten will show.

Can a posterior contract faster than the minimax rate? Not uniformly over a model. If a posterior contracts at a rate epsilon n, the centre of the smallest ball holding half its mass is an estimator that converges at the same rate. So epsilon n can be no faster than the minimax rate. Part fifty's lower bounds, by Le Cam, Fano and Assouad, bind Bayesians as much as anyone.

Numbers: β = 1: fitted slopes −0.249 (α = ½; theory −¼), −0.328 (α = 1; −⅓), −0.218 (α = 2; −⅕)

4Bernstein-von MisesPhD4 min

Bernstein–von Mises: when a posterior is a confidence distribution. The theorem that reconciles Bayesians and frequentists, for parametric models. Take a model that is locally asymptotically normal at the truth, in the sense of Part forty-seven, with nonsingular interior information, posterior localization at the root-n scale, and a prior density continuous and positive there. Then the posterior, in total variation, approaches a normal distribution centred at an efficient estimator with the inverse Fisher information over n as its variance. Sergei Bernstein and Richard von Mises had versions early in the century; Lucien Le Cam gave the modern one. Regular quantile intervals and corresponding ellipsoids then have pointwise asymptotic coverage. Uniform honesty over a class needs additional uniform assumptions.

The proof, in three moves. Zoom in at the root-n scale, with the local parameter h. By local asymptotic normality, the log-likelihood ratio is a quadratic in h, plus a negligible remainder. So the posterior density of h is the prior, evaluated at points converging to theta zero and hence nearly constant, times the exponential of a quadratic: a normal distribution centred at I inverse times the score. The last step uses tests, as in Schwartz's theorem, to show the posterior puts vanishing mass far from the truth, so the local picture is the whole picture.

The theorem made visible. Coin flips with a uniform prior, so the posterior is a Beta, compared by exact integration with the normal centred at the sample proportion. For a probability of point three, the total variation distance falls from at ten flips to at ten thousand. The slope is : the error is of order one over root n, the white reference. The plotted counts are rounded n times the reference probability, rather than averages over data. At zero successes the MLE normal is a point mass and its total variation from the continuous Beta is exactly one. For the interior counts at reference probability two percent the approach is slower, even at ten thousand. Near the edge of the parameter space the posterior stays skewed, and so do the frequentist pivots of Part eleven.

The theorem's other face: the prior washes out. Two analysts see the same coin flips, one with a flat prior and one with a confident prior centred at point nine one, for a truth of point three. The total variation between their posteriors is at ten flips and at ten thousand: they merge, as Bernstein–von Mises promises. But slowly. A prior worth twenty pseudo-observations needs many times that many real ones before its influence disappears.

Does the theorem survive when the number of parameters grows with the sample? For particular growing-dimensional exponential families and priors, sufficient dimension bounds depend on likelihood derivatives, information and prior concentration; a power of p over n alone is not a universal theorem. In Gaussian linear regression, Bontemps obtained prior- and design-dependent bounds. With known variance and a flat prior, the conditional coefficient posterior is exactly Gaussian for any full-rank p less than n. Proportional dimension requires a model-specific analysis. It does not by itself imply that every posterior has the wrong shape or location.

What the theorem does and does not say. It does say that credible regular intervals for smooth finite-dimensional parameters have pointwise asymptotic coverage under the stated assumptions. It says nothing about small samples, parameters near a boundary, or dimensions that grow with n. Nor about misspecified models, where, as chapter eleven shows, the posterior's spread is wrong. And in infinite-dimensional models, the next chapter shows, it can fail outright.

Numbers: TV, p = 0.3: 0.084 (n = 10) → 0.0023 (10⁴); p = 0.02: 0.018 at 10⁴; Beta(1, 1) vs Beta(20, 2): 0.87 → 0.11

5Semiparametric BvM and its failuresPhD5 min

Semiparametric Bernstein–von Mises, and its failures: in infinite dimensions, credible is not confident. In 1993, Dennis Cox showed that for Gaussian-process regression, a ninety-five percent credible band for the regression function can have frequentist coverage close to zero. In 1999, David Freedman showed in the Gaussian white-noise model that the Bernstein–von Mises theorem fails for the function as a whole: the classical strong-norm infinite-dimensional normal approximation can fail. This does not rule out finite-dimensional marginals or BvM in weaker multiscale spaces. The reason is that in infinitely many dimensions the posterior's spread and the posterior mean's error need not be of the same size. A credible ball can be the right size and still be centred in the wrong place, so that the truth falls outside nearly always.

The comparison uses exact finite-coordinate functional coverage and simulated credible-ball coverage, for a truth of smoothness one and ten thousand observations, as the prior's smoothness varies. In gold, the credible ball for the three thousand retained coefficients. The posterior quantile has an independent Monte Carlo reference; uncertainty in that calibration is recorded separately from dataset simulation error. For rough priors it is conservative, covering in all sampled replicates here, with Monte Carlo and radius-calibration uncertainty. As the prior grows smoother than the truth, coverage collapses: percent at one and a quarter, and nearly zero from one and a half on. This is Freedman's phenomenon. In green, the credible interval for a smooth linear functional, a weighted sum of coefficients with weights one over k: it keeps its ninety-five percent almost to alpha two. In teal, a rougher functional, with weights k to the minus point six: it fails sooner and harder, percent at alpha three.

Why. The posterior's spread shrinks at rate n to the minus alpha over one plus two alpha, while the posterior mean's bias for a beta-smooth truth shrinks at n to the minus beta over the same denominator. When the prior is smoother than the truth, the bias dominates the spread: the credible ball is too small for its own error, and misses. When the prior is rougher, the spread dominates: the ball covers, but is wastefully large and the rate is suboptimal. And when the smoothness matches exactly, they are of the same order, so coverage depends on the bias, spread and noise constants. It need not tend to ninety-five percent or even to a nontrivial fraction between zero and one.

Four repairs. Use a rougher prior than the truth: the ball covers, at the price of a slower rate. Inflate the credible ball by a constant factor. Estimate the smoothness from the data and then inflate, the route of chapters eight and nine. Or change the norm: Castillo and Nickl proved Bernstein–von Mises theorems for the whole function in weaker, multiscale norms, where credible sets do cover, and turned them into honest bands.

But for a linear functional, a weighted sum of the coefficients like a mean or an integral, the picture changes. If the weights decay fast, the functional depends mainly on low frequencies, where the data dominate the prior, and the high-frequency bias averages away. Then the marginal posterior of the functional is asymptotically the normal sampling distribution of an efficient estimator: a Bernstein–von Mises theorem for the functional. The lesson, made precise by Ismaël Castillo and Richard Nickl: Bernstein–von Mises can hold for smooth aspects of an infinite-dimensional parameter, while strong-norm infinite-dimensional BvM can fail. Weaker-norm theorems are a distinct possibility.

The general theory is Ismaël Castillo and Judith Rousseau's of 2015. For a smooth functional of the distribution, the marginal posterior is asymptotically normal, centred at an efficient estimator with the efficient variance of Part forty-nine. The condition is that the prior is not too biased in the direction of the efficient influence function. When it is, the posterior can centre in the wrong place, as Vincent Rivoirard and Rousseau showed for densities. And in causal inference, Kolyan Ray and Aad van der Vaart showed in 2020 that aligning the outcome-regression prior with a least-favourable direction involving an estimated propensity score can remove bias under overlap and nuisance-rate conditions. An unrelated prior on the propensity score is not sufficient.

Numbers: n = 10⁴, β = 1: credible ball 100% for α ≤ 1, 76% at 1.25, ≈ 0 from 1.5; Σk⁻¹θₖ ≈ 95% to α = 2, 58% at 3; Σk^−0.6 θₖ 20% at 3

6Dirichlet processes and Polya treesPhD6 min

Dirichlet processes and Pólya trees: priors on distributions. Thomas Ferguson's Dirichlet process of 1973 is a prior on probability distributions. A random distribution F has it if, for every partition of the space, the probabilities F gives the pieces are Dirichlet, with parameters alpha times the base measure's probabilities. It is conjugate: after n observations the posterior is again a Dirichlet process, with concentration alpha plus n and a base measure mixing the prior guess with the empirical distribution. So the posterior mean CDF is the empirical CDF shrunk towards the prior guess, with alpha acting as a prior sample size. But its draws are discrete, almost surely: infinitely many atoms with weights given by Jayaram Sethuraman's stick-breaking. That is why it cannot serve directly as a prior for densities.

Real data: Simon Newcomb's sixty-six measurements of the time light took to travel about seven kilometres, from 1882, which Part thirty used for robustness. The empirical CDF in grey, with its two famous low outliers. The Dirichlet-process posterior mean, with concentration one and a wide normal prior guess, is almost exactly the empirical CDF. Its pointwise credible band, from the Beta distribution of each F of x, is conditional and pointwise, not a simultaneous band or a frequentist coverage guarantee. The normal base uses the same data's median and MAD, so this is an empirical-Bayes illustration rather than a fixed-prior analysis. With alpha equal to one, the prior counts as a single observation, and the data are ninety-eight and a half percent of the answer.

The discreteness, seen through the Blackwell–MacQueen urn of Part twenty-six's Chinese restaurant: each new draw repeats an old value with probability proportional to its count, or makes a new one with probability proportional to alpha. With alpha one, a thousand draws take only about distinct values. The number grows only like alpha times the log of n: ties become common with a continuous base as the sample grows; a finite sample still has positive probability of all distinct values. Rounded continuous measurements may tie too.

In the limit alpha to zero the prior guess disappears, and the posterior is a Dirichlet process on the observed points alone: random weights on the data with a flat Dirichlet distribution. This is Donald Rubin's Bayesian bootstrap of 1981: reweight the observations at random and recompute the statistic. It differs from Efron's bootstrap of Part sixteen only in replacing the multinomial resampling counts with smooth Dirichlet weights. Albert Lo showed in 1987 that under the appropriate smooth-functional and empirical-process conditions the two agree to first order, a Bernstein–von Mises theorem for the bootstrap, and a reason the frequentist bootstrap has a Bayesian reading.

The repair is to smooth the discreteness away. Albert Lo's Dirichlet-process mixture of 1984 draws a discrete distribution of normal components, and mixes the normal densities over it. The result is a random smooth density. Under the stated base-measure, tail and smoothness conditions it has KL support; tests or sieves are also required for consistency. And it is computable: Radford Neal's collapsed Gibbs sampler of 2000 reassigns each observation in turn to an existing cluster or a new one, with the cluster parameters integrated out.

Old Faithful's two hundred and seventy-two eruption lengths, last seen in Part twenty-nine. The averaged predictive density from three chains, seven hundred retained sweeps each, traces both humps. The normal-inverse-gamma base hyperparameters were estimated from these data. But the number of clusters it uses averages , most often . Two density modes need not correspond to exactly two Gaussian components. Several occupied clusters can model the shape of a hump; the scalar cluster trace is a mixing diagnostic, not proof of full convergence. This is no accident: Jeffrey Miller and Matthew Harrison proved in 2014 that the Dirichlet-process mixture's posterior on the number of clusters is inconsistent, even though its density estimate is consistent. Use it for densities, not for counting components.

The other classical prior on distributions is the Pólya tree, studied by Michael Lavine in 1992 and Mauldin, Sudderth and Williams. Split the interval in half, again and again, and at each split send a Beta-distributed fraction of the mass to the left. If the Beta parameters grow fast enough with the level, like the square of the level, the random distribution has a density almost surely, unlike the Dirichlet process. It is conjugate too: the posterior just adds the counts of points in each piece to the Beta parameters. Its weakness is that its densities jump at the dyadic split points, so the partition shows through.

The Dirichlet process has a two-parameter generalization, Jim Pitman and Marc Yor's process of 1997, with a discount d that makes new tables more likely the more tables there already are. With discount strictly between zero and one and valid concentration parameters, the number grows at a power scale. Discount zero is the Dirichlet-process logarithmic case. That matches the power laws of word frequencies and species abundances, which is why it was used for language models before neural networks. And it answers species-sampling questions, how many species have not yet been seen, the Bayesian cousin of Good and Turing's estimator from Bletchley Park.

Numbers: Newcomb, n = 66; tables at n = 1,000: 12 (α = 1), 27 (5), 89 (25); Old Faithful: 5.79 occupied clusters on average across three chains; cluster-count R-hat 1.006, ESS 236

7Gaussian process priorsPhD4 min

Gaussian process priors: rates from the reproducing-kernel Hilbert space and small-ball probabilities. A Gaussian process prior, like Part thirty-nine's Matérn kriging prior, puts a random function in the model. Its reproducing-kernel Hilbert space is the set of shifts h for which W plus h has a law equivalent to W's, the Cameron–Martin space; it is much smaller and smoother than the paths themselves. The small-ball exponent measures how improbable it is for the process to stay within epsilon of zero everywhere. And the concentration function at a truth w zero adds the cost of approximating the truth by an element of the RKHS, half its squared norm, to that small-ball exponent: an approximation term and a complexity term.

Aad van der Vaart and Harry van Zanten's theorem of 2008: if the concentration function at the truth is at most n epsilon squared, the posterior contracts at rate epsilon n, in the specified regression, transformed-density or classification model, in its appropriate loss, under the theorem's link, support and design assumptions. The concentration function verifies both of Ghosal, Ghosh and van der Vaart's conditions at once. For a Matérn prior of smoothness alpha and a truth of smoothness beta in d dimensions, the rate is n to the minus the smaller of alpha and beta, over two alpha plus d. When alpha equals beta it is Stone's minimax rate from Part fifty.

The rate's exponent as a function of the prior's smoothness, for a truth of smoothness one. In white, the theory: rising while the prior is rougher than the truth, falling once it is smoother. In blue, exponents fitted to the exact risks from a thousand to a million observations. The peak is the minimax third, reached only when the smoothness matches: at alpha one. For smoother priors the fitted exponents sit a little above the limit, which they approach only slowly. A Gaussian process prior is minimax for exactly one smoothness, and the truth's is unknown.

The same posteriors seen as functions: the truth in white, a cosine series of smoothness one, and the posterior mean with its pointwise ninety-five percent band, from a thousand observations. A rough prior gives a wiggly mean and a wide pointwise band in this example. A picture does not establish uniform honesty or simultaneous coverage. The matched prior tracks the truth with a moderate band. A smooth prior, alpha three, gives a smooth mean and a narrow band that misses the truth's steep drop: confidently wrong, Cox's phenomenon of chapter five, now in function space.

The same theory covers the popular kernels. The squared-exponential kernel has analytic sample paths, so with a fixed length scale its uniform rates over certain finite-smoothness classes can be only logarithmic. Some particular truths are learned faster. Shrinking the length scale with n can restore the appropriate near-minimax polynomial rate, if you know the truth's smoothness. Van der Vaart and van Zanten showed in 2009 that putting a prior on the length scale can adapt over the smoothness range covered by the hyperprior and theorem, typically with logarithmic factors. And in practice the length scale is usually estimated from the data, which is the empirical Bayes of the next chapter.

Numbers: exponents fitted from exact risks match min(α, β)/(1 + 2α); peak 0.330 at α = 1

8AdaptationPhD4 min

Adaptation: letting the data choose the prior's smoothness. Two ways to choose the smoothness from the data. Empirical Bayes maximizes the marginal likelihood, the probability of the data with the parameter integrated out. Hierarchical Bayes puts a prior on alpha too, and averages. In the sequence model the marginal likelihood is explicit: given alpha, each observation is normal with variance k to the minus one minus two alpha, plus one over n. Bartek Knapik, Botond Szabó and colleagues proved in 2016 that both contract at the minimax rate for every smoothness beta, up to logarithmic factors: the posterior adapts.

One data set of ten thousand observations from a truth of smoothness one. The log marginal likelihood as a function of the prior's smoothness. Its maximum is at . The truth's smoothness is one. The data carry information about their own smoothness, and the marginal likelihood finds it.

Over two hundred independent data sets at each size. The risk is the squared error of the estimator chosen using that very data set, not a fixed-alpha risk formula evaluated after selection. The estimated smoothness averages at a hundred observations and at a million, with its spread shrinking from to . The empirical Bayes posterior's risk is within percent of the best fixed smoothness's at a hundred, and within percent at a million. These are Monte Carlo risk comparisons against the best fixed candidate, with a reported simulation error. They do not prove uniformly negligible adaptation cost.

Why does the marginal likelihood find the smoothness? Set its derivative in alpha to zero. For an interior continuous optimum the score equation matches the observed energy at each frequency, Y k squared, to the energy the prior predicts, lambda k plus one over n, a weighted method of moments. The weights concentrate the information around the frequency where signal and noise are of the same size, about n to the one over one plus two beta. So alpha hat measures the truth's smoothness at the critical frequency, and only there. If the truth behaves differently elsewhere, as an inconvenient truth does, alpha hat is fooled.

The hierarchical alternative puts a prior on alpha and lets the data update it, the posterior over alpha being the prior times the marginal likelihood. That posterior concentrates around the empirical Bayes choice. So asymptotically the two behave the same, with the same rates and the same coverage problems. In small samples, the spread of the posterior over alpha propagates into the credible sets, which can change their width, but does not by itself guarantee better frequentist coverage: the usual argument for being fully Bayesian.

But for uncertainty quantification, adaptation has a price, as Mark Low's theorem in Part fifty warned. The posterior's spread depends on the estimated smoothness. If the data make alpha hat too large, the posterior is too confident and the credible ball too small. For suitable tail-regular truths in the covered regime, and a modestly inflated ball covers. For some truths, alpha hat is fooled, and no fixed inflation rescues coverage at every sample size. Which truths those are is the next chapter's question.

Numbers: α̂: 1.46 (n = 10²) → 1.09 (10⁶); actual selected-estimator risk / fixed-candidate oracle 1.233 ± 0.050 → 0.999 ± 0.007 (MCSE; 200 datasets)

9Credible sets that coverPhD3 min

Botond Szabó, Aad van der Vaart and Harry van Zanten identified the condition in 2015. A truth has a polished tail if the energy beyond any frequency N is at most a constant times the energy in a fixed window just after N. In words: the roughness of the truth at high frequencies is foretold by what is visible a little earlier, so the data can see how smooth the function really is. For such truths, empirical Bayes credible balls, inflated by a fixed constant, have coverage under the theorem's specified tail constants, prior family, inflation and asymptotic regime. An inconvenient truth hides its energy in sparse, widely separated blocks of frequencies. At some sample sizes the data see only smooth parts, empirical Bayes oversmooths, and the ball misses.

Two truths of the same smoothness. The polished one has coefficients decaying steadily like k to the minus three halves, modulated by the sine of k. The inconvenient one has the same decay, but only in blocks starting at two to the j times j plus one, with each block ending at twice its start; the multiplicative gaps grow without bound, with nothing in between, so that at some resolutions it looks much smoother than it is.

The same comparison across sample sizes, without inflation. For the polished truth, coverage stays between and percent in these finite experiments; an inflation guarantee requires the stated regularity and asymptotic conditions. For the inconvenient truth it swings, percent at three hundred observations and at a thousand. At three hundred the estimated smoothness averages : the data have not yet reached the next block of energy, so the function looks smoother than it is. Coverage depends on where n happens to fall relative to the hidden blocks, the finite grid illustrates variation; it does not establish failure for every possible fixed inflation.

So, can a nonparametric credible set be trusted? For smooth functionals, usually yes, by chapter five's Bernstein–von Mises theorems. For a full function, coverage depends on the norm, prior, class and possible inflation; a polished-tail assumption is one route, not the only general possibility. The condition cannot be checked from the data in general. But neither can a frequentist avoid one: Low's theorem concerns supremum-norm bands in specified classes. Adaptive L-two balls have different restrictions and can exist over some limited smoothness ranges. On this point the two schools agree completely. What differs is only where the assumption is written down: in the prior, or in the class of functions over which a frequentist demands coverage, and a careful analysis states it in either case.

Numbers: finite K = 1,500: polished coverage 80–86%; growing-gap blocked truth 52% (n = 300), 92.7% (1,000), 96.7% (30,000); independent radius calibration, not a finite proof of the infinite-dimensional impossibility theorem

10High-dimensional BayesPhD5 min

The sparse normal means problem of Part fifty, from a Bayesian side: n means, s of them non-zero. The spike-and-slab prior makes each mean exactly zero with probability one minus w, and draws it from a heavy-tailed slab otherwise, with w itself given a Beta prior that favours sparsity. Ismaël Castillo, Johannes Schmidt-Hieber and Aad van der Vaart proved in 2015 that suitably scaled heavy-tailed slabs and model-size priors yield squared Euclidean contraction radius of order s log of n over s in the normal-means problem, with regression requiring design and noise scaling conditions. Our fixed-Gaussian-slab demonstration is not that uniform theorem. The horseshoe of Carlos Carvalho, Nicholas Polson and James Scott is a continuous alternative: normal with a half-Cauchy local scale and a global scale tau of about the sparsity proportion. Stéphanie van der Pas, Bas Kleijn and van der Vaart showed in 2014 that suitable global-scale choices attain the minimax squared-error order in the stated sparse regimes.

How the two priors shrink one observation. Without shrinkage the estimate is the observation itself. The spike-and-slab's posterior mean, in gold, is nearly zero for small observations, then rises steeply as the probability of a signal jumps. The horseshoe, in purple, does the same smoothly: its half-Cauchy scale lets large observations escape almost untouched. Both behave like thresholding rules, the Bayesian versions of Part fifty's.

The horseshoe is one member of a family, Nicholas Polson and James Scott's global-local scale mixtures. A global scale tau sets the overall sparsity, estimated or given its own half-Cauchy prior. A local scale for each coordinate, with heavy tails, lets genuine signals escape the shrinkage. The Dirichlet–Laplace prior of Anirban Bhattacharya and colleagues, the R2-D2 prior, and the Bayesian lasso of Part thirty-two are other members; the lasso's light Laplace tails are why it shrinks large signals too much.

But do their credible intervals cover? Four hundred means: three hundred and sixty zeros, ten at one, ten at two and a half, twenty at six, and the marginal ninety-five percent intervals for each. In this finite experiment the zero-signal coverage is very high, while large-signal coverage can still be below ninety-five percent. But for the small signals, the spike-and-slab covers percent and the horseshoe ; for the intermediate ones, and . Sixty independent data sets. The horseshoe uses the known sparsity proportion for its global scale and evaluates forty of the zero coordinates. Monte Carlo errors account for dataset-level grouping. Signals of intermediate size are shrunk towards zero, and the intervals around the shrunken estimates miss them. Van der Pas, Szabó and van der Vaart proved in 2017 that the horseshoe's intervals must fail there, and Richard Nickl and Sara van de Geer had shown in 2013 that honest adaptive confidence sets for sparse vectors are impossible in general.

Computing these posteriors is its own problem. The spike-and-slab posterior lives on two to the p models, and Edward George and Robert McCulloch's Gibbs sampler over inclusion indicators can mix slowly. Veronika Ročková and George replaced the point mass with a narrow continuous spike, which allows a fast EM algorithm to the posterior mode, the spike-and-slab lasso. The horseshoe is sampled by Gibbs with auxiliary scale variables, or by the NUTS sampler of Part twenty-seven. And mean-field variational approximations are fast and estimate well, but Kolyan Ray and Botond Szabó showed that mean-field approximations can underestimate uncertainty; specific contraction theorems do not provide a universal calibration guarantee.

The same pattern as in the last chapter. For estimation, sparse priors are minimax, adaptive and nearly free. For uncertainty, their intervals are honest only for signals that are clearly zero or clearly large. Unfortunately, the intermediate zone is exactly where decisions about which variables matter are made. Part fifty-two's debiased lasso reduces shrinkage but can retain a bias remainder. Its coverage requires approximate-inverse and design assumptions; interval widths are not universally ordered.

Numbers: coverage of 95% intervals by signal size 0, 1, 2.5, 6: spike-and-slab 100, 32, 67, 91%; horseshoe 100, 49, 64, 91%

11Misspecification and generalized posteriorsPractice4 min

When the model is wrong, the truth is outside the family, and the best a model can do is the parameter closest to the truth in Kullback–Leibler divergence, as chapter two's boundary showed. Bas Kleijn and Aad van der Vaart proved in 2012 that under regularity, a unique interior KL minimizer, local nonsingular curvature and posterior concentration, the posterior is asymptotically normal there, with variance the inverse of the model's curvature over n. But the maximum likelihood estimator's actual variance is Huber's sandwich from Part twenty-two, which involves the variance of the score as well. When the two differ, credible sets have the wrong size: the posterior's centre is right and its spread is wrong.

An everyday example. Counts with mean eight and variance forty, two hundred of them, like the overdispersed counts of Part twenty-four. Fit a Poisson model, which assumes the variance equals the mean, and so believes the data five times less noisy than they are. The conjugate posterior for the mean is centred correctly, since the KL-closest Poisson has the true mean, with an average width of . Its ninety-five percent credible intervals cover the true mean only percent of the time.

The repair is a generalized posterior, Pier Giovanni Bissiri, Chris Holmes and Stephen Walker's framework of 2016: raise the likelihood to a power eta. With eta below one, the data count for less and the posterior widens. For this one-dimensional overdispersed Poisson working model, the plug-in mean-to-variance ratio matches the leading sandwich spread. One scalar learning rate cannot generally match a multivariate sandwich matrix. Here the estimated eta is about ; the intervals more than double in width, to , and cover percent.

Is tempering the right fix? Ulrich Müller asked the decision-theoretic question in 2013: if the model is wrong, which posterior minimizes the asymptotic risk of the decisions made from it? His answer: the one with the posterior's variance replaced by the sandwich. A sandwich posterior, centred like the Bayesian one and sized like Huber's. Or, often better, fix the model: a suitable negative-binomial model would address overdispersion, though its own prior and asymptotic calibration still need checking, and would have been the Bayesian's first choice once the overdispersion was noticed.

Sometimes there is no likelihood worth writing down, because the quantity of interest is defined by a loss: a median, a quantile, a classifier's error. A Gibbs posterior replaces the log-likelihood by minus eta times the summed loss. With absolute-error loss it is a posterior for the median that uses a loss instead of a parametric likelihood. Calibration still needs assumptions such as independent observations, a unique regular median, moments and bootstrap validity, the Bayesian analogue of Part thirty's robust estimators. Its learning rate can be calibrated by the bootstrap, as Nicholas Syring and Ryan Martin proposed in 2019, to target frequentist coverage under the calibration procedure's assumptions. It is not an exact distribution-free guarantee.

How should eta be chosen? For calibrated uncertainty, match the sandwich, as here. For prediction, Peter Grünwald's SafeBayes chooses eta to stop a wrong model from overfitting. Grünwald and Thijs van Ommen showed in 2017 that without it, a standard Bayesian linear regression with misspecified noise can be inconsistent, adding ever more spurious complexity. And replacing the log-likelihood by any loss gives Gibbs posteriors, the objects of Part fifty-four's PAC-Bayes bounds.

Numbers: Poisson width 0.78, coverage 62.3%; tempered (η ≈ 0.2) width 1.75, coverage 94.6%

Recap, problems, and the road aheadAll tracks2 min

Part fifty-three in twelve lines. Diaconis and Freedman's reasonable prior that is wrong forever. Doob's consistency, almost surely under the prior. Schwartz's two ingredients. Contraction rates, and the contraction ball. Bernstein–von Mises, its failures, and its rescue for functionals. Dirichlet processes and Pólya trees. Gaussian processes through their reproducing kernels and small balls. Adaptation by empirical Bayes. Polished tails on the Board. The spike-and-slab and the horseshoe. And misspecified models with tempered posteriors.

A promise for the next part. This one asked when posteriors find the truth, how fast, and when credible sets can be trusted. All of it assumed a likelihood, a model of how the data arise. Part fifty-four drops the model: statistical learning theory asks why minimizing a loss on a sample generalizes at all, and ends with Gibbs posteriors in PAC-Bayes form.

Where it comes back. Part fifty-four bounds the risk of Gibbs posteriors by PAC-Bayes. Part fifty-six asks about credible sets after selection. Part fifty-eight builds anytime-valid tests from Bayesian mixtures. Part sixty-two returns to Bayesian causal inference with propensity-score priors. And Part sixty-four asks whether Bayesian deep learning is calibrated.

Six problems, with full solutions in the README. Doob for a finite parameter set; the boundary posterior; the sequence model's risk; the Beta posterior's moments; the Dirichlet process's moments; and the tempered posterior's variance. Pause here if you want to try them.

The books this part follows: Ghosal and van der Vaart's Fundamentals of Nonparametric Bayesian Inference, Ghosh and Ramamoorthi, Giné and Nickl's seventh chapter, and Hjort, Holmes, Müller and Walker's collection; with the papers from Doob to Grünwald and van Ommen.

Fifty-three parts of sixty-five. A prior is an assumption, and in infinite dimensions assumptions do not wash out by themselves. The good news is that the conditions under which Bayesian methods estimate well are now precisely known, and they are mild. The harder news is that honest uncertainty, Bayesian or not, always rests on an assumption about the truth that the data cannot fully check. Next, Part fifty-four: statistical learning theory.

Where it goes next. PAC-Bayes bounds for Gibbs posteriors follow in Part 54, credible sets after selection in Part 56, anytime-valid tests from Bayesian mixtures in Part 58, Bayesian causal inference in Part 62 and the calibration of Bayesian deep learning in Part 64; Problem 12 of the qualifying exam (Part 55) is a contraction rate.

Key results

The part's results in one place, for revision.

Schwartz's theorem\(\displaystyle \Pi\bigl(p:\operatorname{KL}(p_0\,\|\,p)<\varepsilon\bigr)>0\ \ \forall\varepsilon>0\ \text{ and }\allowbreak \text{exponentially }\allowbreak \text{powerful }\allowbreak \text{tests }\allowbreak \text{of } p_0 \text{ against } U^c\ \Longrightarrow\ \Pi(U^c\mid X_1,\dots,X_n)\to0\ \text{a.s.}\)
The posterior in the sequence model\(\displaystyle Y_k=\theta_k+\frac{Z_k}{\sqrt n},\ \theta_k\sim N(0,\lambda_k):\qquad\allowbreak \theta_k\mid Y\sim N\Bigl(\frac{n\lambda_k}{1+n\lambda_k}Y_k,\ \frac{\lambda_k}{1+n\lambda_k}\Bigr)\)
Its contraction rate\(\displaystyle \lambda_k=k^{-1-2\alpha},\ \theta_0\ \text{of }\allowbreak \text{regularity }\beta:\qquad\allowbreak \varepsilon_n=n^{-\frac{\min(\alpha,\beta)}{1+2\alpha}},\quad\allowbreak \text{minimax } n^{-\frac{\beta}{1+2\beta}} \text{ iff } \alpha=\beta\)
Bernstein-von Mises\(\displaystyle \Bigl\|\Pi(\cdot\mid X_1,\dots,X_n)-N\bigl(\hat\theta_n,\ (nI_{\theta_0})^{-1}\bigr)\Bigr\|_{\mathrm{TV}}\ \xrightarrow{\ P_{\theta_0}\ }\ 0\)
The Dirichlet process is conjugate\(\displaystyle P\sim\operatorname{DP}(\alpha,G_0),\ X_i\mid P\overset{\text{iid}}{\sim}P:\qquad\allowbreak P\mid X\sim\operatorname{DP}\Bigl(\alpha+n,\ \frac{\alpha G_0+\sum_i\delta_{X_i}}{\alpha+n}\Bigr)\)
The tempered posterior\(\displaystyle \pi_\eta(\theta\mid x)\ \propto\ \pi(\theta)\,p(x\mid\theta)^\eta,\qquad\allowbreak 0<\eta\le1\)

Try it

Lab 53 · Contraction rates and credible balls in the Gaussian sequence model

With a truth of regularity beta = 1 and priors theta_k ~ N(0, k^(-1-2 alpha)), fit the posterior mean's rate from its exact risk and compare it with n^(-min(alpha, beta)/(1 + 2 alpha)); then measure how often the 95% credible ball contains the truth as alpha passes beta, and how fast a Beta posterior becomes normal.

Figure produced by Lab 53: Contraction rates and credible balls in the Gaussian sequence model
Produced by the lab below, seed 0, in 0.6 s.
python -m videos.stats.labs 53 needs numpy, scipy, matplotlib · download lab53.py · source on GitHub
prior alpha = 0.5: fitted exponent of the posterior mean's error             -0.248   theory -0.250
prior alpha = 1.0: fitted exponent of the posterior mean's error             -0.328   theory -0.333
prior alpha = 2.0: fitted exponent of the posterior mean's error             -0.218   theory -0.200
alpha = 1, n = 10^4: simulated risk of the posterior mean                    0.002140   exact 0.002121
alpha = 0.5: 95% credible ball covers the truth                              100.0%   radius 0.1307   mean distance to the truth 0.0883
alpha = 0.75: 95% credible ball covers the truth                             100.0%   radius 0.0813   mean distance to the truth 0.0564
alpha = 1.0: 95% credible ball covers the truth                              98.7%   radius 0.0595   mean distance to the truth 0.0458
alpha = 1.25: 95% credible ball covers the truth                             72.8%   radius 0.0484   mean distance to the truth 0.0457
alpha = 1.5: 95% credible ball covers the truth                              0.5%   radius 0.0427   mean distance to the truth 0.0521
alpha = 2.0: 95% credible ball covers the truth                              0.0%   radius 0.0348   mean distance to the truth 0.0738
Bernstein-von Mises, p = 0.3: TV(Beta posterior, normal) at n = 10 ... 10^4  0.0843  0.0243  0.0074  0.0023

The posterior contracts at the minimax rate only when the prior's smoothness matches the truth's; an oversmoothing prior is slower and its credible ball, too small for its own bias, misses the truth almost always.
The code (72 lines; it asserts its own result)
"""Lab 53: how fast a Gaussian-prior posterior contracts, and when its credible ball stops covering."""

import numpy as np

from videos.coursekit import labs
from explainer.stats.kit import bnp

TITLE = "Contraction rates and credible balls in the Gaussian sequence model"
GOAL = ("With a truth of regularity beta = 1 and priors theta_k ~ N(0, k^(-1-2 alpha)), fit the posterior mean's rate "
        "from its exact risk and compare it with n^(-min(alpha, beta)/(1 + 2 alpha)); then measure how often the 95% "
        "credible ball contains the truth as alpha passes beta, and how fast a Beta posterior becomes normal.")
TASKS = [
    "Choose alpha by empirical Bayes (bnp.eb_alpha) on each simulated dataset and recompute the credible ball's "
    "coverage with the chosen alpha.",
    "Use bnp.functional_coverage with a_k = 1/k and then a_k = k^(-0.6) at alpha = 3. Which linear functional keeps "
    "its 95%?",
    "Change the truth's regularity beta to 2 and find the alpha with the fastest rate. Is it still alpha = beta?",
]


def run(seed=0):
    rng = np.random.default_rng(seed)
    lab = labs.Lab()
    beta, K = 1.0, 20000
    theta = bnp.sobolev_truth(K, beta)
    ns = np.array([10 ** 2, 10 ** 3, 10 ** 4, 10 ** 5, 10 ** 6])
    alphas = (0.5, 1.0, 2.0)
    rms = {a: np.array([np.sqrt(bnp.risk(theta, int(n), bnp.prior_var(K, a))["risk"]) for n in ns]) for a in alphas}
    for a in alphas:
        slope = np.polyfit(np.log(ns), np.log(rms[a]), 1)[0]
        theory = -min(a, beta) / (1 + 2 * a)
        lab.row(f"prior alpha = {a}: fitted exponent of the posterior mean's error", f"{slope:.3f}   theory {theory:.3f}")
        assert abs(slope - theory) < 0.03, "the contraction rate n^(-min(alpha, beta)/(1 + 2 alpha))"
    assert rms[1.0][-1] < rms[0.5][-1] and rms[1.0][-1] < rms[2.0][-1], "matching the truth's smoothness is fastest"

    # one simulated check of the exact risk
    n, Ks = 10 ** 4, 1500
    th, lam = theta[:Ks], bnp.prior_var(Ks, 1.0)
    Y = th + rng.standard_normal((400, Ks)) / np.sqrt(n)
    sim = float(np.mean(np.sum((bnp.posterior(Y, n, lam)["mean"] - th) ** 2, axis=1)))
    exact = bnp.risk(th, n, lam)["risk"]
    lab.row("alpha = 1, n = 10^4: simulated risk of the posterior mean", f"{sim:.6f}   exact {exact:.6f}")
    assert abs(sim / exact - 1) < 0.05, "the simulated risk is the exact one"

    grid = [0.5, 0.75, 1.0, 1.25, 1.5, 2.0]
    cover = [bnp.credible_ball_coverage(th, n, bnp.prior_var(Ks, a), reps=1500, rng=rng) for a in grid]
    for a, c in zip(grid, cover):
        lab.row(f"alpha = {a}: 95% credible ball covers the truth", f"{c['coverage']:.1%}   radius {c['radius']:.4f}   "
                f"mean distance to the truth {c['dist']:.4f}")
    assert all(c["coverage"] > 0.97 for c in cover[:3]), "a rougher prior than the truth is conservative"
    assert cover[4]["coverage"] < 0.05 and cover[5]["coverage"] < 0.01, "a smoother prior is confidently wrong"

    tv = [bnp.bvm_tv_beta(int(round(0.3 * m)), m) for m in (10, 100, 1000, 10000)]
    lab.row("Bernstein-von Mises, p = 0.3: TV(Beta posterior, normal) at n = 10 ... 10^4", "  ".join(f"{t:.4f}" for t in tv))
    assert all(x > 2.5 * y for x, y in zip(tv, tv[1:])) and tv[-1] < 0.005, "TV falls like n^(-1/2)"
    lab.note = ("The posterior contracts at the minimax rate only when the prior's smoothness matches the truth's; "
                "an oversmoothing prior is slower and its credible ball, too small for its own bias, misses the "
                "truth almost always.")

    fig, ax = labs.figure(2, size=(11, 4.2))
    for a, color in zip(alphas, (labs.BLUE, labs.GOLD, labs.RED)):
        ax[0].loglog(ns, rms[a], "o-", color=color, label=f"alpha = {a}: theory n^(-{min(a, beta) / (1 + 2 * a):.2f})")
    ax[0].set(title="Error of the posterior mean, truth of regularity 1", xlabel="n", ylabel="root of the exact risk")
    ax[0].legend()
    ax[1].plot(grid, [c["coverage"] for c in cover], "o-", color=labs.GOLD, label="coverage of the 95% credible ball")
    ax[1].axhline(0.95, color=labs.MUTED, ls="--")
    ax[1].axvline(beta, color=labs.GREEN, ls=":", label="the truth's regularity beta = 1")
    ax[1].set(title="Is the credible ball honest? n = 10,000", xlabel="prior regularity alpha", ylabel="coverage",
              ylim=(-0.03, 1.05))
    ax[1].legend(loc="lower left")
    lab.fig = fig
    return lab

Now change it

  1. Choose alpha by empirical Bayes (bnp.eb_alpha) on each simulated dataset and recompute the credible ball's coverage with the chosen alpha.
  2. Use bnp.functional_coverage with a_k = 1/k and then a_k = k^(-0.6) at alpha = 3. Which linear functional keeps its 95%?
  3. Change the truth's regularity beta to 2 and find the alpha with the fastest rate. Is it still alpha = beta?

Problems, with solutions

Try each problem before opening its solution.

  1. Doob for a finite prior. Prove Doob's theorem for a prior on finitely many \(\theta\): show \(\Pi(\theta_0 \mid X_{1:n}) \to 1\) by the LLN for log-likelihood ratios.

    Solution
    • Π(θ | X) ∝ π(θ) exp(Σᵢ log p_θ(Xᵢ)).
    • For θ ≠ θ₀, (1/n) Σ log(p_θ/p_θ₀)(Xᵢ) → −KL(θ₀, θ) < 0 almost surely, so each wrong θ's posterior weight relative to θ₀'s is π(θ)/π(θ₀) · e^{−n KL + o(n)} → 0.
    • With finitely many θ, Π(θ₀ | X) → 1.
  2. The boundary posterior. For \(X_i \sim N(0, 1)\) and a Uniform\([1, 3]\) prior on the mean, show the posterior mean tends to 1.

    Solution
    • The posterior is N(x̄, 1/n) truncated to [1, 3]. Since x̄ → 0, almost all of the untruncated mass lies below 1.
    • The truncated normal piles up at 1, with mean 1 + O(1/(n|x̄ − 1|)) → 1: the KL projection of 0 onto [1, 3].
  3. The sequence model's risk. In the sequence model, derive the posterior mean's risk \(\sum (1 - w_k)^2\theta_k^2 + \sum w_k^2/n\), \(w_k = n\lambda_k/(1 + n\lambda_k)\).

    Solution
    • θ̂ₖ = wₖYₖ = wₖθₖ + wₖZₖ/√n, so θ̂ₖ − θₖ = −(1 − wₖ)θₖ + wₖZₖ/√n.
    • Squaring and taking expectations: (1 − wₖ)²θₖ² + wₖ²/n. Sum over k.
  4. The Beta posterior's moments. Show the Beta\((a + k, b + n - k)\) posterior's mean and variance match \(\hat p\) and \(\hat p(1 - \hat p)/n\) up to \(O(1/n)\).

    Solution
    • The mean (a + k)/(a + b + n) = p̂ + O(1/n).
    • The variance (a + k)(b + n − k)/((a + b + n)²(a + b + n + 1)) = p̂(1 − p̂)/n + O(1/n²).
  5. Dirichlet-process moments. For \(F \sim \mathrm{DP}(\alpha, G_0)\), show \(E[F(A)] = G_0(A)\) and \(\mathrm{Var}[F(A)] = G_0(A)(1 - G_0(A))/(\alpha + 1)\).

    Solution
    • F(A) ~ Beta(αG₀(A), α(1 − G₀(A))), from the partition {A, Aᶜ}.
    • So E F(A) = G₀(A), and Var F(A) = G₀(A)(1 − G₀(A))/(α + 1).
  6. The tempered posterior's variance. Show the tempered Gamma–Poisson posterior with \(\eta = \mu/\sigma^2\) has variance \(\approx \sigma^2/n\), the sandwich.

    Solution
    • Gamma(a + ηΣy, b + ηn) has variance (a + ηΣy)/(b + ηn)² ≈ ȳ/(ηn).
    • With η = μ/σ², this is ≈ σ²/n, the variance of ȳ: the sandwich, since for the mean parameter μ, the Poisson score is y/μ − 1 with variance σ²/μ² and the expected negative Hessian is 1/μ. The resulting sandwich variance is σ²/n. A scalar temperature does not generally match a multivariate sandwich covariance.

Notes and sources

Where it comes back

  • Part 54: PAC-Bayes bounds for Gibbs posteriors.
  • Part 56: credible sets after selection.
  • Part 58: anytime-valid tests from Bayesian mixtures.
  • Part 62: Bayesian causal inference with propensity-score priors.
  • Part 64: the calibration of Bayesian deep learning.

Glossary

  • Consistency.
    • Posterior consistency; Doob's theorem; KL support; exponentially consistent tests; sieve; Hellinger distance: when the posterior finds the truth.
    • Contraction rate; prior mass condition; entropy condition; small-ball probability; RKHS; concentration function: how fast.
  • Shape.
    • Bernstein–von Mises; LAN; total variation; merging of opinions: parametric.
    • Credible ball; linear functional; semiparametric BvM; efficient influence function; multiscale norm: nonparametric.
  • Priors.
    • Dirichlet process; base measure; concentration; Chinese restaurant; stick-breaking; DP mixture; Pólya tree; Pitman–Yor: on distributions.
    • Gaussian process; Matérn; squared exponential; length scale: on functions.
    • Spike-and-slab; complexity prior; horseshoe; global-local; Dirichlet–Laplace: on sparse vectors.
  • Adaptation and honesty.
    • Empirical Bayes; marginal likelihood; hierarchical Bayes; polished tail; inconvenient truth; inflation: adaptive credible sets.
    • Misspecification; KL projection; sandwich; tempered (fractional) posterior; Gibbs posterior; SafeBayes: wrong models.

Sources

  • Consistency. J. Doob, Colloq. Int. CNRS 13 (1949); L. Schwartz, Z. Wahrsch. 4 (1965); D. Freedman, Ann. Math. Stat. 34 (1963); P. Diaconis & D. Freedman, Ann. Stat. 14 (1986); A. Barron, M. Schervish & L. Wasserman, Ann. Stat. 27 (1999).
  • Rates. S. Ghosal, J. Ghosh & A. van der Vaart, Ann. Stat. 28 (2000); S. Ghosal & A. van der Vaart, Ann. Stat. 29 (2001); W. Shen, S. Tokdar & S. Ghosal, Biometrika 100 (2013); A. van der Vaart & H. van Zanten, Ann. Stat. 36 (2008), 37 (2009); B. Knapik, A. van der Vaart & H. van Zanten, Ann. Stat. 39 (2011).
  • Bernstein–von Mises. L. Le Cam (1953, 1986); D. Cox, Ann. Stat. 21 (1993); D. Freedman, Ann. Stat. 27 (1999); S. Ghosal, J. Multivar. Anal. 74 (2000); D. Bontemps, Ann. Stat. 39 (2011); I. Castillo & R. Nickl, Ann. Stat. 41 (2013), 42 (2014); I. Castillo & J. Rousseau, Ann. Stat. 43 (2015); V. Rivoirard & J. Rousseau, Bayesian Anal. 7 (2012); K. Ray & A. van der Vaart, Ann. Stat. 48 (2020).
  • Nonparametric priors. T. Ferguson, Ann. Stat. 1 (1973); D. Blackwell & J. MacQueen, Ann. Stat. 1 (1973); J. Sethuraman, Stat. Sinica 4 (1994); A. Lo, Ann. Stat. 12 (1984); R. Neal, JCGS 9 (2000); S. Ghosal, J. Ghosh & R. V. Ramamoorthi, Ann. Stat. 27 (1999); M. Lavine, Ann. Stat. 20 (1992); J. Pitman & M. Yor, Ann. Probab. 25 (1997); J. Miller & M. Harrison, JMLR 15 (2014).
  • Adaptation and coverage. B. Knapik, B. Szabó, A. van der Vaart & H. van Zanten, PTRF 164 (2016); B. Szabó, A. van der Vaart & H. van Zanten, Ann. Stat. 43 (2015); R. Nickl & S. van de Geer, Ann. Stat. 41 (2013).
  • Sparse priors. E. George & R. McCulloch, JASA 88 (1993); I. Castillo, J. Schmidt-Hieber & A. van der Vaart, Ann. Stat. 43 (2015); C. Carvalho, N. Polson & J. Scott, Biometrika 97 (2010); S. van der Pas, B. Kleijn & A. van der Vaart, EJS 8 (2014); S. van der Pas, B. Szabó & A. van der Vaart, Bayesian Anal. 12 (2017); V. Ročková & E. George, JASA 109 (2014); A. Bhattacharya et al., JASA 110 (2015); K. Ray & B. Szabó, JASA 117 (2022).
  • Misspecification. B. Kleijn & A. van der Vaart, EJS 6 (2012); U. Müller, Econometrica 81 (2013); P. Bissiri, C. Holmes & S. Walker, JRSS B 78 (2016); N. Syring & R. Martin, Biometrika 106 (2019); P. Grünwald & T. van Ommen, Bayesian Anal. 12 (2017).
  • Data. S. Newcomb (1891); S. Stigler, Ann. Stat. 5 (1977); W. Härdle, Smoothing Techniques (1991).
  • Books. S. Ghosal & A. van der Vaart, Fundamentals of Nonparametric Bayesian Inference (2017); J. K. Ghosh & R. V. Ramamoorthi, Bayesian Nonparametrics (2003); E. Giné & R. Nickl (2016), ch. 7; N. Hjort, C. Holmes, P. Müller & S. Walker (eds.), Bayesian Nonparametrics (2010).
About this partfrom its README

Part 53 of a sixty-five-part course in statistics, from a first course to a PhD (see the series plan and the syllabus), and the eleventh part of Stage IV, the PhD core.

It opens with Diaconis and Freedman (1986). In a symmetric location problem, a reasonable prior (a smooth prior on the centre and a symmetrized Dirichlet process with a Cauchy base on the shape) has a posterior that never settles at the true centre. The part asks when a posterior finds the truth, how fast, and whether its credible sets are honest:

  • Doob's theorem (1949), proved by martingales, and Freedman's warning;
  • Schwartz's theorem (1965): KL support plus tests; Barron–Schervish–Wasserman sieves;
  • contraction rates (Ghosal, Ghosh & van der Vaart 2000), exact in the Gaussian sequence model, and the contraction ball;
  • Bernstein–von Mises from LAN, priors merging, growing dimension;
  • its infinite-dimensional failures (Cox 1993; Freedman 1999), BvM for smooth functionals, and Castillo & Rousseau's semiparametric BvM;
  • Dirichlet processes, the Chinese restaurant, DP mixtures on Old Faithful, Pólya trees, Pitman–Yor;
  • Gaussian-process priors through the RKHS and small-ball probabilities;
  • adaptation by empirical and hierarchical Bayes;
  • polished tails and inconvenient truths (Szabó, van der Vaart & van Zanten 2015), on the Board;
  • spike-and-slab and the horseshoe: rates, shrinkage, and coverage by signal size (Board);
  • misspecification (Kleijn & van der Vaart 2012), tempered and Gibbs posteriors, SafeBayes (Board).

It keeps three promises:

  • Part 26 said the prior washes out as data accumulate. Chapters 1–5 say when it does, at what rate, and when it does not.
  • Part 47's LAN gives the Bernstein–von Mises theorem in chapter 4.
  • Part 50's minimax rates are attained by posteriors in chapters 3 and 7–10, and bind them from below.

Built in this part:

  • statkit.bnp (explainer/stats/kit/bnp.py), tested in tests/test_stats_kit_bnp.py:
    • the Gaussian sequence model with Gaussian priors: posterior, exact risk and spread, credible-ball coverage, exact coverage of credible intervals for linear functionals, the marginal likelihood and empirical Bayes;
    • Bernstein–von Mises: TV between a Beta posterior and its normal approximation;
    • misspecification: Poisson credible intervals for overdispersed counts and a calibrated tempered posterior;
    • the Dirichlet process: posterior CDF and Beta bands, the Pólya urn, stick-breaking, and a collapsed Gibbs sampler for DP mixtures of normals (Neal's Algorithm 3);
    • sparse normal means: the spike-and-slab posterior with a Beta-binomial weight, its intervals; the horseshoe's posterior by quadrature.
  • The contraction ball (ContractionBall in explainer/stats/viz.py), the part's instrument: the truth, posterior draws and a credible disc in a two-dimensional window onto parameter space, drawn at a fixed scale so that panels for different n compare.

Data.

  • From the Museum: Newcomb's passage times (1882) and Old Faithful's eruptions.
  • The rest is exact arithmetic or seeded simulation.

The Coverage Board gains six rows:

Method Setting Nominal Achieved Verdict
EB credible ball, polished truth sequence model, β = 1, n = 10⁴ 95% 84.7% broken
EB credible ball, growing-gap blocked truth sequence model, β = 1, n = 10⁴ 95% 97.0% kept
EB credible ball inflated 1.5×, polished truth sequence model, β = 1, n = 10⁴ 95% 100% conservative
horseshoe interval, intermediate signals sparse means, θᵢ = 2.5, n = 400 95% 64% broken
Poisson credible interval, overdispersed counts NB, mean 8, var 40, n = 200 95% 62.3% broken
tempered (generalized) posterior interval NB, mean 8, var 40, n = 200 95% 94.6% kept
Chapter notes
# Chapter Numbers
0 Diaconis and Freedman the symmetrized DP location model
1 Doob 24 truths from a uniform prior: mean error 0.008 after 3,000 flips; a three-point prior: the truth's posterior → 1
2 Schwartz N(0, 1) data, a Uniform[1, 3] prior: posterior mean 1.114 (n = 10), 1.010 (100), 1.001 (1,000)
3 Contraction rates β = 1: fitted slopes −0.249 (α = ½; theory −¼), −0.328 (α = 1; −⅓), −0.218 (α = 2; −⅕)
4 Bernstein–von Mises TV, p = 0.3: 0.084 (n = 10) → 0.0023 (10⁴); p = 0.02: 0.018 at 10⁴; Beta(1, 1) vs Beta(20, 2): 0.87 → 0.11
5 Semiparametric BvM n = 10⁴, β = 1: credible ball 100% for α ≤ 1, 76% at 1.25, ≈ 0 from 1.5; Σk⁻¹θₖ ≈ 95% to α = 2, 58% at 3; Σk^−0.6 θₖ 20% at 3
6 Dirichlet processes Newcomb, n = 66; tables at n = 1,000: 12 (α = 1), 27 (5), 89 (25); Old Faithful: 5.79 occupied clusters on average across three chains; cluster-count R-hat 1.006, ESS 236
7 Gaussian processes exponents fitted from exact risks match min(α, β)/(1 + 2α); peak 0.330 at α = 1
8 Adaptation α̂: 1.46 (n = 10²) → 1.09 (10⁶); actual selected-estimator risk / fixed-candidate oracle 1.233 ± 0.050 → 0.999 ± 0.007 (MCSE; 200 datasets)
9 Credible sets finite K = 1,500: polished coverage 80–86%; growing-gap blocked truth 52% (n = 300), 92.7% (1,000), 96.7% (30,000); independent radius calibration, not a finite proof of the infinite-dimensional impossibility theorem
10 High-dimensional Bayes coverage of 95% intervals by signal size 0, 1, 2.5, 6: spike-and-slab 100, 32, 67, 91%; horseshoe 100, 49, 64, 91%
11 Misspecification Poisson width 0.78, coverage 62.3%; tempered (η ≈ 0.2) width 1.75, coverage 94.6%
12 Outro —
The syllabus's plan for this partfrom SYLLABUS.md, the plan of record
  1. Hook: Diaconis & Freedman (1986). Upgrade card from Part 26.
  2. Doob's theorem (1949), proved (Part 44).
  3. Schwartz's theorem (1965). KL support plus tests.
  4. Contraction rates (Ghosal, Ghosh & van der Vaart 2000). Prior mass, entropy and tests.
  5. Bernstein–von Mises, parametric, via LAN (Le Cam).
  6. Semiparametric BvM (Castillo & Rousseau 2015) and its failures (Cox 1993; Freedman 1999).
  7. Dirichlet processes and Pólya trees. Posterior consistency for densities.
  8. Gaussian process priors. Rates via RKHS and small-ball probabilities (van der Vaart & van Zanten 2008).
  9. Adaptation. Hierarchical and empirical Bayes priors.
  10. Credible bands. When they cover; polished tails (Szabó, van der Vaart & van Zanten 2015) (Board).
  11. High-dimensional Bayes. Spike-and-slab (Castillo, Schmidt-Hieber & van der Vaart 2015); the horseshoe (van der Pas, Kleijn & van der Vaart 2014).
  12. Misspecification and generalized posteriors. Kleijn & van der Vaart (2012); Gibbs posteriors and SafeBayes (Grünwald).
  13. Outro.

Built: statkit.bnp. Books: Ghosal & van der Vaart; Ghosh & Ramamoorthi; Giné & Nickl ch. 7.

Build the film

python -m videos.stats.stats53.compute        # the part's numbers, into .cache/stats53
python tools/build.py stats53                  # render and assemble the film
EXPLAINER_TTS=silent python tools/qa_scene.py stats53 Hook   # one chapter, silent, with a contact sheet

Scenes: videos/stats/stats53. 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.stats53.compute   # once (a few minutes)
python tools/build.py stats53 -q l                         # fast 480p preview
python tools/build.py stats53                              # 1080p30 -> renders/stats53.mp4
python tools/qa_scene.py stats53 Bands
python tools/lecture_length.py stats53 --floor 50