Distribution-Free Inference
What can be guaranteed with no assumptions about the distribution, and what is impossible?
Bahadur and Savage's 1956 paper opens the part: over all distributions with a finite mean, no interval of bounded length covers the mean with probability bounded away from zero. A mixture of a standard normal with a rare value at 3 over epsilon has mean exactly 3, and at n = 50 it drives the 95% t-interval's coverage to 14%, while split conformal covers the next draw from the same mixture 95.8% of the time. The difference is the functional: the next observation is exchangeable with the ones in hand, so its rank is uniform. The rank strip proves the quantile lemma, coverage exactly k/(n + 1), with the Beta law of coverage given the calibration set; full conformal, split conformal and the jackknife+ follow, with the proof of 1 - 2 alpha. Then the part turns to what cannot be had: coverage conditional on x forces infinite length, and no distribution-free interval exists for a regression function. Between the two lie the relaxations: conditional guarantees over function classes, weighted and nonexchangeable conformal with a total-variation bound, adaptive conformal inference on a drifting series, conformal p-values for outliers on the Wisconsin biopsies, and risk control. It ends on NHANES blood pressures, where marginal calibration covers 78.3% of adults over seventy and group-conditional calibration 90.7%.
What you need. Stages I to IV of the series: Part 34's conformal methods as algorithms, order statistics and the Beta law, total variation, linear programming for quantile regression, and Part 46's testing theory.
- Hook
- Bahadur & Savage's impossibility, 1956
- Mathematics
- exchangeability, full/split/jackknife+ conformal proofs, impossibility theorems, conditional guarantees, beyond exchangeability, conformal p-values
- Built
- statkit.conformal (II)
What you will be able to do
Bachelor's
- Explain with the mixture of the cold open why no sample of fifty can pin down a mean, and why the median and the next observation are different.
- Compute split conformal's threshold from n calibration scores, k = ceil((n + 1)(1 - alpha)), and its exact coverage k/(n + 1).
Master's
- Prove the quantile lemma from exchangeability, and derive the Beta(k, n + 1 - k) law of coverage given the calibration set.
- Derive the long-run coverage bound of adaptive conformal inference from its update rule.
PhD
- Prove the jackknife+ guarantee of 1 - 2 alpha by the tournament argument, and give the unstable fit on which the plain jackknife fails.
- State and prove the impossibility of distribution-free conditional coverage, and state the guarantee of Gibbs, Cherian and Candes over a finite-dimensional function class with its slack.
- State the nonexchangeable conformal bound and compute its total-variation term for a changepoint.
Practice
- Check a deployed conformal method by group: report coverage in each subgroup, not only overall, and recalibrate by Mondrian or group-conditional thresholds where it fails.
- State with every conformal interval the sampling assumption it rests on (exchangeability, a known shift, or none with an online update), the calibration size, and that the guarantee is marginal.
Contents
Each chapter has a home level. Choose a track to see what to read and watch: Bachelor's 15 min · Master's 23 min · PhD 54 min · Practice 23 min.
- 0Bahadur and Savage, 1956Bachelor's5 min
- 1Exchangeability and the quantile lemmaBachelor's7 min
- 2Full, split and jackknife+PhD5 min
- 3ImpossibilityPhD4 min
- 4Conditional guarantees over function classesPhD4 min
- 5Beyond exchangeabilityPhD4 min
- 6Online and adversarialPhD4 min
- 7Conformal p-values and outlier testingPractice4 min
- 8Risk controlPhD4 min
- 9Mondrian and group-conditional coveragePractice4 min
- 10Open problemsPhD5 min
- 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.
Bahadur and Savage, 1956Bachelor's5 min
In 1956 Raghu Raj Bahadur and Leonard Savage published a short paper with a forbidding title: the nonexistence of certain statistical procedures. Over the family of all distributions with a finite mean, no confidence interval for the mean, of any bounded length, has coverage bounded away from zero; and no test about the mean has power greater than its size. The reason is simple. A finite mean is a weak condition: a tiny probability of a huge value can move the mean anywhere. And a sample of any fixed size will usually not contain that value. So distribution-free inference cannot mean inference about the mean with no assumptions at all.
A concrete family makes the argument visible. Mix a standard normal with a small probability epsilon of a single value, three over epsilon. Every member of the family has mean exactly three. But the chance that a sample of n contains the far-away value is small when epsilon is small: the sample misses it with probability one minus epsilon to the n. When it does, the sample looks exactly like standard normal data, and the t-interval sits near zero, nowhere near the true mean of three.
Distribution-free inference for prediction is older than it looks. In 1941 Samuel Wilks built tolerance intervals from order statistics: independent identically distributed observations and continuity, without a parametric family. The interval between two order statistics covers at least a fraction beta of the population, with a probability that can be computed exactly. The reason is that the distribution function evaluated at the k-th order statistic has a Beta distribution, whatever the distribution is: the probability integral transform makes every continuous law uniform. The same fact returns in chapter one, seventy years later, as the exact law of conformal coverage.
The t-interval's coverage across the family, with fifty observations. Every distribution has mean three. As epsilon shrinks, the simulated coverage falls: at epsilon three in a thousand. It follows the bound set by the chance of seeing no atom at all. At epsilon one in a thousand it is , and it approaches the tiny, positive no-atom coverage at this fixed mean and sample size. To make the general impossibility limit zero, the hidden mean shift must also be allowed to grow. Whatever n you fix, some member of the family defeats it.
The numbers behind the chart. With fifty observations and epsilon three in a thousand, the chance that the sample contains no atom is point nine nine seven to the fiftieth, about eighty-six percent. In that case the data are plain normal and the interval sits near zero, nowhere near the mean, so the coverage is at most about fourteen percent, as the simulation showed. Shrink epsilon tenfold, and only one and a half percent of samples ever see an atom. Yet the mean is exactly three throughout, carried by a value so rare and so far away that no sample of fifty can be expected to find it.
What changed between the two rows? The mean is a functional of the distribution that a rare event can move without limit. The next observation is different: it is exchangeable with the ones we already have. So its rank is uniform when ties are absent or independently randomized; conservative handling of ties still gives coverage. This part is about what that one fact guarantees, and about the theorems that say what it cannot.
Bahadur and Savage's paper has a second theorem, about tests. Over the family of all distributions with a finite mean, every test of a hypothesis about the mean has power no larger than its size against every alternative: it cannot do better than a coin. The family is simply too rich. But tests of the median are fine: the sign test of Part sixteen is exact and powerful over every continuous distribution. The lesson is that the functional decides what is possible, not the cleverness of the method: the median cannot be moved by a rare value, and the mean can.
Two promises come due. Part thirty-four showed by experiment that split conformal covers at least one minus alpha, assuming exchangeability, on average. Chapters one to three prove it, and prove what cannot be had. Part fifty-six's conformal selection used independent sampling or its theorem's specified conditional exchangeability assumptions. Chapters four to nine go beyond it, and ask for conditional guarantees.
Numbers: n = 50, mixture mean 3: t-interval coverage 95% (ε = 0.3), 63.5% (0.02), 22.1% (0.005), 14.2% (0.003; bound 13.9%), 5.5% (0.001); P(no atom) = 0.997⁵⁰ = 0.861
1Exchangeability and the quantile lemmaBachelor's7 min
Exchangeability, and the quantile lemma that everything else rests on. Exchangeability: the joint law of the n plus one data points is unchanged by any permutation. Independent and identically distributed data are exchangeable, but so is sampling without replacement from a finite population, which is not independent. De Finetti's theorem, from Part forty-three, says infinite exchangeable sequences are exactly mixtures of i.i.d. ones. And that is all distribution-free prediction assumes: the test point is exchangeable with the calibration points. Nothing about the distribution itself.
This part's instrument is the rank strip. With nineteen calibration scores and one test score, there are twenty possible ranks for the test score, and, assuming almost surely distinct scores, exchangeability makes each rank equally likely. If the threshold is the eighteenth smallest calibration score, the test point is covered whenever its rank is eighteen or less: the green slots. It is missed in the top two: the red. Drop test points at random, and they land uniformly. The coverage is exactly eighteen twentieths, ninety percent, whatever their distribution, provided there are no ties; randomization or conservative ranks handle ties.
The proof in four lines. Apply any fixed score function, say the absolute residual of a model fitted on separate data, to each point: the scores are exchangeable too. Use the minimal rank, one plus the number of scores strictly smaller. Its probability of being at most k is at least k over n plus one. With almost surely distinct scores the rank is uniform and equality holds. Take the threshold to be the k-th smallest calibration score, with k the ceiling of n plus one times one minus alpha, or infinity if k exceeds n. The test score is below the threshold exactly when its rank is at most k, so the coverage is at least that ceiling over n plus one, which is at least one minus alpha.
Without ties the coverage is exactly k over n plus one, so the guarantee is also an upper bound: it never exceeds one minus alpha plus one over n plus one. With four calibration points it is a hundred percent, because no finite threshold is small enough; with ten, ninety point nine; with a hundred and one, ninety point two; with two hundred and fifty, ninety point zero four. Conformal prediction is neither conservative nor anticonservative: it is exact, up to one over n.
Some worked numbers. With nineteen calibration scores and alpha a tenth, k is the ceiling of twenty times point nine, eighteen: the eighteenth smallest score is the threshold, and the coverage is eighteen in twenty, exactly ninety percent. With twenty scores, k is nineteen and the coverage nineteen in twenty-one, ninety and a half percent: a little over. With only eight scores, k would be nine, more than there are, and the interval is the whole line. In general a finite interval at level one minus alpha needs at least one minus alpha over alpha calibration points: nine at ninety percent, ninety-nine at ninety-nine percent.
With discrete scores, such as classification probabilities, ties make the coverage at least k over n plus one rather than equal to it. Breaking ties with an independent uniform variable restores exactness, just as Part forty-six's randomized tests did. The smoothed conformal p-value counts the calibration scores above the test score, plus a uniform fraction of the ties. Under exchangeability it is exactly uniform, whatever the distribution.
The guarantee is on average over the calibration set too. Draw four thousand calibration sets of a hundred. Each gives one interval, and that interval has some coverage of future points. With independent identically distributed continuous scores, conditional on separately trained models, that coverage has a Beta distribution, with parameters k and n plus one minus k. Its mean is , but percent of calibration sets give intervals that cover less than eighty-five percent. A larger calibration set concentrates it, with variance about alpha times one minus alpha over n: choose n with that in mind.
The Beta law is Wilks's fact for independent identically distributed continuous scores. Mere exchangeability is not enough for the Beta law. Given the calibration set, the interval's coverage of a future point is the score distribution F evaluated at the threshold, the k-th order statistic. F of the scores are n independent uniforms, so F of the k-th score is the k-th uniform order statistic, which is Beta with parameters k and n plus one minus k: mean k over n plus one, variance about alpha times one minus alpha over n. That gives a stronger guarantee with a width cost: choose k a little larger, and with probability one minus delta over the calibration set, the coverage itself is at least one minus alpha. Vovk calls this training-conditional validity.
With a hundred calibration points at alpha a tenth, k is ninety-one and the coverage, given the calibration set, is Beta with parameters ninety-one and ten: mean ninety point one percent, standard deviation three points. Its five percent quantile is eighty-four point eight percent: one deployment in twenty gets a calibration set that leaves it below that. To guarantee ninety percent coverage with probability ninety-five percent over the calibration set, take k equal to ninety-six instead. The cost is a wider interval: the ninety-sixth of a hundred scores, not the ninety-first.
Split conformal prediction is the lemma applied. Fit any model on one part of the data, and compute absolute residuals on the other. The interval is the prediction plus or minus their inflated quantile, and it covers a new point with probability at least one minus alpha. Any separately trained model preserves marginal validity under the required exchangeability. A bad score can hurt width and subgroup coverage. Validity is free; efficiency is not, and comes from better scores, such as conformalized quantile regression or residuals divided by a fitted spread.
Numbers: n = 19: k = 18, coverage 18/20; n = 20: 19/21 = 90.5%; finite only if n ≥ 9 at α = 0.1; n = 100: Beta(91, 10), mean 90.1%, SD 3.0, 5% quantile 84.8%, 5.9% of 4,000 calibration sets below 85%; PAC k = 96
2Full, split and jackknife+PhD5 min
Full, split and jackknife plus conformal: using every observation twice, honestly. Full conformal prediction, the original form by Vladimir Vovk, Alexander Gammerman and Glenn Shafer, uses all the data for both jobs. For each candidate value y of the new outcome, refit the model on all n plus one points, with the test point labelled y. Compute every point's residual under that fit. When y is the true value, the model treats the test point exactly like the others, so the residuals are exchangeable. Keep every y whose residual is not among the largest alpha fraction: the lemma, inverted. The cost is a refit for every candidate y, affordable only for models like ridge regression or the lasso, whose fits move simply with y.
A comparison: ridge regression with forty observations and five features, two hundred repetitions. Full conformal covers percent, with median length . Split conformal, fitting on twenty and calibrating on twenty, covers percent, with median length . Both are valid; full conformal is about percent shorter, because it sets no data aside.
Full conformal is affordable when the fit moves simply with the candidate label. For the lasso, Jing Lei showed that the coefficients are piecewise linear in y, so the residuals are too, and the prediction set can be found exactly by tracing the breakpoints, as LARS traces the lasso path. For ridge regression, every residual is linear in y, and the set is a union of intervals found in one pass. For general models, approximate: a grid of candidates or a first-order influence-function expansion. A bare finite grid can omit tails and holes and has no exact continuum guarantee. Our ridge calculation instead solves all absolute-residual crossings analytically and retains the union of intervals.
Between the two extremes is the jackknife: fit n models, each leaving one point out, and record each point's leave-one-out residual. The naive jackknife puts the full fit's prediction plus or minus the quantile of those residuals. It has no guarantee, and Part thirty-four showed it failing for an interpolating fit. Barber, Candès, Ramdas and Tibshirani's jackknife plus uses the leave-one-out predictions at the test point instead of the full fit, shifted by each residual. Its coverage is at least one minus two alpha for any permutation-symmetric fitting algorithm under exchangeability, using the prescribed finite-sample order statistics. Stability refinements require their additional conditions.
The proof is a tournament. Imagine fitting the algorithm on every subset of n minus one of all n plus one points, including the test point. For each pair of points, record which one has the larger residual under the fit that left both out. A counting argument shows that at most two alpha times n plus one points can each lose to one minus alpha times n plus one others. The jackknife plus interval fails only if the test point is one of these, and by exchangeability that has probability at most two alpha.
For stable algorithms, those whose predictions change little when one point is left out, in Part fifty-four's sense, jackknife plus covers at least one minus alpha, minus terms that vanish with the stability parameter. Stability can justify appropriately inflated jackknife intervals or asymptotic validity under continuity conditions. A small prediction perturbation alone does not prove uninflated finite-sample coverage. Only for unstable algorithms, such as the interpolating fits of Part fifty-four, does the distinction matter, and then only jackknife plus keeps a guarantee, the weaker one minus two alpha.
The menu, then. Split conformal: one fit, coverage at least one minus alpha, but half the data wasted. Cross-validation plus: K fits, and a guarantee slightly below one minus two alpha. Jackknife plus: n fits, at least one minus two alpha. Full conformal: a fit for every candidate, at least one minus alpha, with no universal ordering of interval length. The trade is always computation against data; validity is never the price.
The ledger of costs. Split conformal fits once, but only half the data trains the model and the rest calibrates it, which can increase width and variability; there is no pointwise ordering against full conformal. Jackknife plus fits n times, once per left-out point, and every point both trains and calibrates: with a thousand points, a thousand fits. CV plus with K folds fits K times, ten for ten folds, and sits between them. And full conformal fits once for every candidate label at every test point, which is affordable only when a homotopy, like the lasso's, traces all the refits at once.
Numbers: ridge, n = 40, p = 5, 200 reps: full 90.0% (median total set length 3.583), split 90.0% (4.04)
3ImpossibilityPhD4 min
Impossibility: what no distribution-free method can do. The lemma's guarantee is marginal: coverage on average over the test point's features. What a patient wants is conditional coverage: given my features, the interval covers my outcome with probability one minus alpha. The two can be very different: marginal coverage of ninety percent can hide a subgroup covered half the time. So the obvious goal is conditional coverage, uniformly over all sampling distributions, beyond the IID sampling setup.
An example: a regression whose noise grows across the range of x. Split conformal with absolute residuals covers percent overall, as promised. But it covers everyone where the noise is small, and only percent where it is large. Dividing the residuals by a fitted spread evens it out, with percent overall and every bin close to ninety. But that works only because the spread model happens to be right, which is an assumption.
And the impossibility. Suppose a procedure has conditional coverage for every distribution, at every point x that is not an atom. Vladimir Vovk, and Jing Lei and Larry Wasserman, proved that its intervals must then have infinite expected length at almost every such point. The idea is Bahadur and Savage again, locally: near a non-atom there are almost no data, so any conditional law can be hidden there. Exact conditional coverage, distribution-free, forces infinite intervals.
The practical response is local conformal prediction: calibrate within bins, or neighbourhoods, of x. For a fixed partition chosen separately from calibration labels, Mondrian calibration gives at least nominal coverage within each bin. Arbitrary overlapping neighborhoods are not automatically such a partition. But as the bins shrink, each holds fewer calibration points, the inflated quantile grows, and in the limit the intervals become infinite, exactly as the theorem says. Resolution in x trades against interval length: the old bias–variance trade-off in a new form.
In numbers: twelve hundred calibration points in ten bins leave a hundred and twenty in each, and the threshold is the hundred-and-ninth of them. With a hundred bins, twelve in each, the threshold is already the largest score in the bin. With two hundred bins, six in each, k would be seven, and every interval is the whole line. If every bin must have enough calibration observations for a finite threshold, there can be at most about a hundred and thirty-three such bins. Equal occupancy is an idealization; random sparse bins can be infinite sooner.
A relaxation asks for coverage over every subset of feature space with probability at least delta. Barber, Candès, Ramdas and Tibshirani proved lower bounds on the length of any interval achieving that, too. What is possible is coverage over a chosen, finite family of groups or shifts: the Mondrian idea of chapter nine. And the next chapter's generalization, from Isaac Gibbs, John Cherian and Candès, gives exact coverage over a whole function class.
Functionals of the distribution are worse. For a binary outcome, consider a confidence interval for the conditional probability that Y is one, given X equals x. Rina Foygel Barber proved distribution-free lower bounds for intervals on the conditional response probability at a random feature. There is no uniform shrinking-length guarantee across all non-atomic models; this is not a claim that every particular model has a positive lower bound. An unrestricted mean and a pointwise regression function face these obstacles. Marginal quantiles and medians do have distribution-free order-statistic confidence intervals under IID sampling. The boundary depends on the functional and the model class, not simply on prediction versus parameter estimation.
Numbers: heteroscedastic regression: plain split 88.9% overall, 100% where the noise is small, 57% where it is large; normalized residuals 89.9%, 86–93% in every bin; 1,200 points allow at most 133 bins at α = 0.1
4Conditional guarantees over function classesPhD4 min
Gibbs, Cherian and Candès start from a reformulation. Conditional coverage is equivalent to the miscoverage being uncorrelated with every function of x. Each such function, if it is a density ratio, describes a covariate shift: coverage under the reweighted test distribution. Asking for all functions is impossible, as chapter three showed. Asking for a chosen class is not: coverage under every shift in that class. When the class is spanned by group indicators, that means at least nominal coverage within every prespecified group under IID sampling, even with overlap. The randomized dual version can make the moment equations exact.
The method is quantile regression with a twist. Fit the one minus alpha quantile of the scores over the class F by minimizing the pinball loss, with the test point included at an imagined score S. The prediction set keeps every y whose score is below the fitted quantile at x, computed with that very score included. For a finite-dimensional class each fit is a linear programme, and its test-point dual variable is monotone in S. We invert that dual variable with verified brackets, which avoids treating a primal interpolation plateau as the acceptance criterion. For constants the conservative dual construction recovers the inflated empirical-quantile threshold up to numerical tolerance.
Computing it takes one quantile regression, a linear programme, for each candidate score. Because the dual variable is monotone in the score, bracketed bisection finds the boundary. A separate geometry LP detects when every score must be accepted. For a class of group indicators, test points with the same pattern of memberships share a threshold, so the work is one bisection per pattern; that is how our NHANES calculation runs. And a small randomization makes the coverage exact instead of conservative, as with ties in chapter one.
Why is it exact? The quantile-regression first-order conditions make its subgradient residual orthogonal to the class. Points on the fitted boundary require subgradients, not an unqualified equality for binary indicators. We choose solutions symmetrically in all observations. The test point is one of those n plus one, exchangeable with the rest. So in expectation its miscoverage is orthogonal to every nonnegative function in the class, with a weighted moment error bounded by dimension over n plus one times the expected maximum weight, under conditional score continuity. Dividing by a group's probability introduces that probability in the denominator. For group indicators, that is coverage of at least one minus alpha within every group, in finite samples.
Against Mondrian: Mondrian handles disjoint groups, simply and exactly. Conditional calibration handles overlapping groups, covariate shifts, and smooth classes of functions. For marginal coverage, a continuity-based upper slack is dimension over n plus one. For a group of prevalence pi it is dimension divided by n plus one times pi, capped at one. Small groups can have much larger slack. So a large class needs a large calibration set, and the class should be chosen with that budget in mind.
For infinite classes, such as a reproducing-kernel Hilbert space or all Lipschitz shifts, they add a penalty to the quantile regression. Coverage under each shift then holds up to an error that can be estimated from the data. The class is a dial, between marginal coverage, with only the constants, and the impossible, with every function. The paper appeared in the Journal of the Royal Statistical Society in 2025.
Numbers: 11 basis columns, rank 9, n = 1,200: marginal upper slack ≤ 9/1,201; a group upper bound divides by its prevalence
5Beyond exchangeabilityPhD4 min
Beyond exchangeability: when the future does not look like the past. The first step beyond exchangeability was covariate shift, seen in Part thirty-four: test features come from a different distribution, but the outcome's law given the features is unchanged. Weight each calibration score by the likelihood ratio of the two feature distributions. Take the one minus alpha quantile of the weighted scores, with the test point's weight placed at infinity. Ryan Tibshirani, Barber, Candès and Ramdas showed this is exactly valid when the weights are known, because the data are then weighted exchangeable.
In practice the weights are estimated, usually by a classifier trained to tell test features from calibration features. For independently estimated, nonnegative weights normalized to integrate to one, the coverage loss is bounded by half the reference-law expectation of their absolute density-ratio error. Raw classifier odds need normalization and the correct class-prior factor. Lihua Lei and Candès used exactly this for causal inference: the treated group's outcomes are a covariate-shifted version of the population's, under unconfoundedness and overlap, weighted conformal can predict missing potential outcomes. Intervals for their difference need a further construction; the unobserved joint potential-outcome law is not identified automatically. Double robustness is an asymptotic guarantee under specified nuisance rates and regularity conditions, not automatic finite-sample exactness from a correct mean model alone.
For data that are not exchangeable at all, such as a time series that drifts, Barber, Candès, Ramdas and Tibshirani fix weights in advance, for example geometrically decaying ones that count recent points more. With no assumption on the data, the coverage is at least one minus alpha, minus a weighted sum of total-variation distances. Each distance measures how much the data's law changes when point i and the test point are swapped. For exchangeable data every distance is zero and the old guarantee returns; under drift, recent weighting helps when the recent points have smaller swap distances. The bound can be vacuous for arbitrary drift.
Other departures have their own weights. Under label shift the outcome's distribution changes while the features given the outcome do not, and the weights depend on y. For time series, methods use blocks of data, mixing conditions, or decaying weights. For spatial data, weights by distance to the prediction site. The common idea: say which past points resemble the future, and weight them. In the nonexchangeable framework that is a modelling choice that affects efficiency and the size of the coverage loss, not a promise of near-nominal coverage without controlling those distances.
A series whose noise jumps from one to two and a half at time one thousand, with the last three hundred points as the calibration set at each step. With equal weights, coverage in the three hundred steps after the jump falls to percent, because most of the calibration window still remembers the quiet regime. With weights decaying by a factor of point nine nine per step, it recovers to percent. Over the whole series, against percent. Recent points carry the information about now.
The bound in numbers. Fifty steps after the jump, two hundred and fifty of the three hundred past points come from before it. Swapping one of them with the current point changes the joint distribution by a total variation of about point five two. With equal weights the stale points carry eighty-three percent of the weight, so the guaranteed loss is up to forty-three points: coverage at least forty-seven percent. With weights decaying by point nine nine per step they carry fifty-eight percent, the loss is at most thirty points, and coverage is at least sixty percent. Loose, but honest, and the chart shows the truth is better.
Numbers: jump in the noise SD at t = 1,000: equal weights 77% in the 300 steps after, ρ = 0.99 weights 86%; overall 87.3% vs 89.8%; TV bound 50 steps after: coverage ≥ 47% (equal) vs ≥ 60% (ρ = 0.99), swapped-pair TV 0.52
6Online and adversarialPhD4 min
Online and adversarial coverage: guarantees with no probability model at all. Part thirty-four showed adaptive conformal inference at work; here is its guarantee. At each time, predict a set at level one minus alpha t, then see the outcome. Record whether it was missed. Isaac Gibbs and Candès update the working level by gamma times alpha minus the miss: after a miss, widen; after a hit, narrow slightly. Then the long-run miss rate is within a constant over gamma T of alpha, for every finite-valued sequence, adversarial included, provided alpha starts in the unit interval, gamma is positive, and out-of-range levels produce whole or empty sets. Long-run frequency can be maintained at the cost of uninformative sets.
Here it is on chapter five's drifting series, with three hundred past scores and a working level one minus alpha t. With gamma zero, this is plain split conformal on a moving window: in the three hundred steps after the jump it covers percent. With gamma one in two hundred, the misses lower alpha and widen the intervals and coverage recovers to percent; the overall miss rate is percent. With gamma two in a hundred, percent after the jump, and percent misses overall. Larger gamma recovers faster, and pays with sets that jump around.
The proof is two lines. Summing the update telescopes: the change in alpha over T steps is gamma times the total of alpha minus the misses. And alpha t cannot run away: if it drops below zero the set becomes everything and cannot miss, which pushes it back up; above one the set is empty, misses for certain, and is pushed back down. So the total deviation is bounded, and dividing by T gives the guarantee. No probability was used anywhere: it is a statement about every sequence, in the spirit of Part fifty-four's online learning.
How long is the long run? With alpha a tenth and gamma one in two hundred, the bound is nine hundred and five thousandths over gamma T: a hundred and eighty-one over T. For the seventeen hundred steps of our chart that is plus or minus ten points: a worst case, and uninformative. To be within one point needs eighteen thousand one hundred steps. With gamma four times larger it needs a quarter as many, at the price of jumpier sets. The guarantee is for every sequence, so it is conservative for any particular one.
The step size gamma matters. Small gamma gives stable sets that are slow to react to a change; large gamma reacts quickly but makes the sets jump around. Gibbs and Candès's later method runs many values of gamma at once and combines them with exponential weights, the Hedge algorithm of Part fifty-four. Its adaptive regret and coverage results have their own assumptions and bounds; they are not the identical fixed-gamma telescoping inequality. The displayed simulation uses fixed-gamma ACI.
What it says, and what it does not. The long-run frequency of misses tends to alpha for any data. It says nothing about any single time, or about any subgroup. Gamma trades fast adaptation against stable sets, and later work adapts gamma itself. And the same online-learning idea, of controlling a cumulative error against every sequence, will give anytime-valid tests in Part fifty-eight.
Numbers: the same series: γ = 0 77% after the jump (miss rate 12.7%), γ = 0.005 89% (9.9%), γ = 0.02 90% (10.1%); 16 whole-line sets at γ=0.02; bound 181/T, within one point needs T ≥ 18,100
7Conformal p-values and outlier testingPractice4 min
Outlier detection turns the lemma into a test. There is an IID clean reference set of inliers, independent of test units and of the separate score-training sample. A score, trained on separate inliers, is large for unusual points: a distance from the bulk, or a one-class classifier's output. A test point's conformal p-value is one plus the number of reference points scoring at least as high, over n plus one. If the test point really is an inlier, the p-value is valid, by the quantile lemma.
What the p-values look like, pooled over twenty random splits of the Wisconsin biopsies. For the benign test biopsies, the inliers, the histogram is approximately flat in this fixed-data resplitting experiment: each tenth of the unit interval holds about a tenth of them. For the malignant ones, the outliers, percent sit at p-values of two hundredths or less, near the smallest value a reference set of a hundred and fifty-seven allows, one in a hundred and fifty-eight. A roughly uniform null reference and alternatives concentrated near the minimum: the picture every multiple-testing method of Part thirty-three wants.
With many test points, the p-values share one reference set and are dependent. Stephen Bates, Candès, Lihua Lei, Yaniv Romano and Matteo Sesia proved that the inliers' p-values are positively dependent in the required sense. So Benjamini–Hochberg on them controls the false discovery rate: the fraction of flagged points that are really inliers. They also gave guarantees conditional on the reference set, at a slightly stricter level, which is the practitioner's real situation: one reference set, many uses.
A practical limit. The smallest conformal p-value is one over n plus one. Benjamini–Hochberg rejects k hypotheses only if the k-th smallest p-value is at most q k over m. For exactly k rejections, the resolution condition is n plus one at least m over q k. BH can still reject a larger set, so this is not a prerequisite for any rejection whatsoever. Screening ten thousand points for ten outliers at q a tenth needs at least nine thousand nine hundred and ninety-nine reference inliers for exactly ten rejections. Our biopsies make the point: with a hundred reference points and a hundred and forty-seven tests, at least fifteen outliers had to reach the smallest p-value, and some splits rejected nothing; with a hundred and fifty-seven reference points and ninety tests, six suffice.
The score can be any novelty detector: a distance from the bulk, an isolation forest, the reconstruction error of an autoencoder, or a one-class support vector machine. Validity holds for any of them, as long as it is trained on inliers separate from the reference set. Power depends on how well the score separates the outliers. What must never happen is training the score on the reference set itself, because the reference scores would then be systematically smaller than a new inlier's.
The Wisconsin biopsies again, now as outlier detection: benign tissue is the reference population, malignant the outliers. The score is the distance from the centre of a hundred and fifty benign biopsies, each feature in their standardized units, with a hundred and fifty-seven more as the reference set. The test set holds the other benign biopsies and forty malignant ones, and Benjamini–Hochberg runs at a tenth. Over fifty random splits of this one fixed dataset, the average false discovery proportion is percent and the power percent. No model of what malignant tissue looks like was used: only what benign tissue looks like.
Numbers: Wisconsin, 150 benign fit the score, 157 reference, 50 benign + 40 malignant tests, BH q = 0.1, 50 splits: FDR 5.6%, power 72.8%; pooled over 20 splits, 64% of malignant p ≤ 0.02
8Risk controlPhD4 min
Risk control: beyond coverage, to any monotone loss. Anastasios Angelopoulos, Stephen Bates, Adam Fisch, Lihua Lei and Tal Schuster generalized the lemma from coverage to any bounded loss that shrinks as the prediction set grows. Coverage is the special case where the loss is the miss indicator. But the loss could be the fraction of an image's tumour pixels missed by a segmentation, or of a document's correct labels missed by a tagger: a false negative rate. Choose lambda as the smallest value whose empirical risk, slightly inflated, is at most alpha, on a fixed finite grid with a feasible certified threshold. Otherwise the rule must report that no threshold was certified.
The proof copies the lemma's. Define an oracle lambda prime using all n plus one losses, including the test point's. The real lambda hat is at least as large, because its inflation assumed the worst value for the unseen loss. The oracle is a symmetric function of the n plus one points, so the test point's expected loss at it equals the average loss, at most alpha, on a fixed finite grid with a feasible certified threshold. Otherwise the rule must report that no threshold was certified. And since the loss shrinks as lambda grows, the expected loss at lambda hat is no larger.
In numbers: with a hundred calibration examples, losses bounded by one, and alpha a tenth, the rule needs a hundred times the empirical risk, plus one, over a hundred and one, to be at most a tenth. That is an empirical risk of at most nine point one percent, not ten. The extra B is a worst-case loss for the unseen test point, exactly as the plus one is in the quantile lemma. As n grows the margin vanishes, and the chosen lambda can approach the first feasible population-risk level under consistency and crossing conditions. Exact equality is not automatic for discrete losses or a fixed grid.
For losses that are not monotone in lambda, such as precision, the proof fails. Learn then test, from Angelopoulos and colleagues, turns risk control into multiple testing: for each lambda on a grid, test the hypothesis that its risk exceeds alpha. Controlling the family-wise error over the grid, with Part thirty-three's tools, guarantees that with probability one minus delta, the chosen lambda's risk is at most alpha, on a fixed finite grid with a feasible certified threshold. Otherwise the rule must report that no threshold was certified. It requires valid risk tests, a calibration sample independent of training, and proper family-wise error control. If no candidate passes, abstain or use a separately justified safe fallback.
A multilabel screen: twenty candidate labels per unit, about fifteen percent of them true, and a noisy scorer. In teal, the calibration set's false negative rate as lambda grows and the sets include more labels. Lambda hat is , the first value under a tenth after the inflation. On twenty thousand new units the false negative rate is , with sets of about labels. Averaged over two hundred calibration sets, : the theorem is in expectation over calibration and the future unit. This finite Monte Carlo average is an estimate with sampling uncertainty.
The same tool reaches language models. Split a model's answer into claims, and keep only those whose confidence exceeds lambda, so increasing lambda prunes claims. Let the loss be whether any kept claim is false: it is nonincreasing as lambda grows and fewer claims are kept. Calibrate lambda on documents whose claims were checked by hand. Then, for an exchangeable new prompt, the chance that the filtered answer contains an error is at most alpha: a guarantee about a black box, which is Part sixty-four's subject.
Numbers: 20 candidate labels, n = 500, FNR at α = 0.1: λ̂ = 0.595, test FNR 8.9%, mean set size 8.2, mean FNR over 200 calibration sets 9.7%; n = 100 needs R̂ ≤ 9.1%
9Mondrian and group-conditional coveragePractice4 min
The oldest answer to subgroup coverage is Vovk's Mondrian conformal prediction: calibrate separately within each group. By the lemma applied within each group, every group gets at least one minus alpha. A single Mondrian partition is disjoint. Refining to all age-sex-race intersection cells can cover their unions, but may leave sparse cells and infinite thresholds. The class method borrows structure across overlapping groups. Chapter four's method does it, with the class spanned by all the group indicators.
Two groups, with fifty and five hundred calibration points, at alpha a tenth. In the small group the threshold is the forty-sixth score, and coverage is forty-six in fifty-one, ninety point two percent, with a standard deviation of four points across calibration sets. In the large group, the four hundred and fifty-first score: ninety point oh percent, standard deviation one point three. Both are exact on average, within each group. But the small group's realized coverage varies three times as much: a guarantee for minorities is only as sharp as the data on them.
NHANES, the 2017 to 2018 survey: predict systolic blood pressure from age, sex and body-mass index by least squares, and build ninety percent intervals, over random splits. Marginal split conformal covers percent overall, but percent of people over seventy, whose pressures vary more, and percent of those under thirty. Mondrian calibration by age band fixes the age rows, but not the others. The group-conditional method, with the age, sex and race indicators together, is compared across all ten named groups. These are repeated splits of one survey extract, with no population survey weighting or cluster correction. They are not independent national cohorts or a population-wide clinical guarantee.
The same numbers as bars, one pair per group. The marginal method's bars, in red, run from percent for the group to percent for the group: the right average, made of wrong parts. The group-conditional bars, in green, all sit within points of the ninety percent line, though the groups overlap: everyone belongs to an age band, a sex and a race group at once.
How much did it cost? The design has eleven basis columns, but two linear redundancies leave dimension nine: the intercept is the sum of age indicators and also the sum of sex indicators. With twelve hundred calibration points, the marginal continuity-based upper slack is at most dimension over twelve hundred and one. For an individual group divide that bound by its population prevalence; it can be much larger than one percent. Small groups get correct coverage on average, and their observed coverage is noisy. The Beta formula for an ordinary within-group order statistic is not an exact law for this overlapping-group optimizer. So name groups you can afford to calibrate: that is a design decision, made before the data arrive.
Why this matters. A marginal guarantee can be met by over-serving the majority and under-serving a minority. Group-conditional coverage is a fairness requirement that can be stated and audited. Its price is wider intervals in the harder groups, and enough calibration data in each. And the groups must be named in advance: chapter three's impossibility still forbids coverage for every group at once.
Numbers: NHANES, 5,176 adults, 8 splits: marginal 89.5% overall, 98.6% (18–29), 78.3% (70+), 85.7% (race 4); Mondrian by age fixes ages only (race 4 86.0%); group-conditional 88.6–91.0% in every row
10Open problemsPhD5 min
The part in one table. A new outcome can be covered marginally and exactly, assuming only exchangeability; and within each named group, with the same assumption. Coverage at every single x is impossible with finite intervals. Under drift, coverage degrades by a total-variation term, with no assumption. Online, the long-run frequency of misses is controlled for any sequence. Unrestricted means and conditional response probabilities have limits on informative confidence intervals. Trivial whole-space intervals remain valid, and marginal medians and quantiles have distribution-free confidence intervals.
A checklist for reading a distribution-free claim. What is being covered: an observable outcome, or a parameter of the distribution? Is the guarantee marginal, conditional on named groups, or under a shift? Is exchangeability plausible, or are weights needed? And how large is the calibration set, which decides how much the realized coverage can vary from one deployment to another?
Six open problems. First, choosing the function class from the data without losing the guarantee. Second, efficiency: the shortest sets that keep the guarantee, and optimal scores. Third, dependence: sharp guarantees for time series and spatial data, with total-variation terms one can estimate. Fourth, guarantees conditional on the calibration set that are not wasteful. Fifth, structured outputs, such as sets of graphs or texts, and risk control for language models. And sixth, the weakest assumptions under which a functional of the distribution becomes estimable at all.
Problem one in more detail. The group-conditional guarantee depends on a class of functions chosen in advance. Can it be chosen from the data? For penalized infinite classes, such as kernel functions with a ridge penalty, Gibbs, Cherian and Candès give coverage with a slack that can be estimated. But choosing the class on the calibration data is Part fifty-six's problem again: selection invalidates the guarantee. Splitting the data off for the choice is valid, and wasteful. What is open is a way to adapt the class with exact coverage and no data thrown away.
Problem two: efficiency. Validity is free; length is not. Which sets are shortest among those that keep the guarantee? Asymptotically the answer is known: with appropriate consistency and regularity, density-level or quantile constructions can approach their corresponding oracle sets, as Lei, Robins and Wasserman showed for density level sets. In finite samples the choice of score is everything, as Part thirty-four's comparison of residuals and quantile regression showed. A finite-sample theory of optimal scores is open.
Problem three: dependence. Time series, spatial data and networks are not exchangeable. Chapter five's theorem bounds the loss by weighted total-variation terms, but those terms are unknown, and rarely estimable from the data, so the bound is not a number one can report. Sharp guarantees under mixing conditions, building on work such as Chernozhukov, Wüthrich and Zhu's on block structures, and weights that may be chosen from the data without breaking the theorem, are open.
Problem four: the deployed model. A practitioner has one training set and one calibration set, and wants coverage given them, not on average over data they never saw. For split conformal, chapter one's Beta law gives that, a probably-approximately-correct guarantee. For full conformal and jackknife plus, Michael Bian and Barber showed there is no such guarantee in general. Which algorithms, under what stability, earn one is open.
Problem five: structured outputs. What is a prediction set of graphs, of paragraphs, of trajectories? Chapter eight's conformal factuality, from Christopher Mohri and Tatsunori Hashimoto, controls errors by filtering claims. But a set must be usable, not just valid: a set of a million possible paragraphs is correct and useless. Guarantees when the stream of prompts drifts, and set shapes a person can act on, are open.
Problem six, the part's theme. Which functionals of a distribution admit intervals under IID sampling without a parametric family? Bahadur and Savage: not the mean. David Donoho showed in 1988 that one-sided bounds exist for functionals that are semicontinuous in the right sense, such as a lower bound on the number of modes of a density. Between these, the weakest assumptions that make a given functional estimable, and the price of each, remain to be mapped.
Recap, problems, and the road aheadAll tracks2 min
Part fifty-seven in eleven lines. No informative finite-width uniformly honest mean interval exists over all finite-mean distributions. The quantile lemma makes prediction exact to within one over n. For IID continuous scores, coverage conditional on the calibration set has a Beta law. Full, split, jackknife plus and cross-validation plus trade computation for data. Conditional coverage needs infinite intervals, while the possibility of parameter confidence intervals depends on the functional; marginal quantiles are possible. Coverage over a chosen function class is possible, and exact. Weights carry the guarantee beyond exchangeability. Online, ACI controls the miss rate for every sequence. The same lemma tests for outliers and controls risks. And on NHANES, every named group can be covered at once.
A promise for the next part. The rank-based interval guarantees concern a fixed sample; the ACI chapter separately controls a long-run error frequency. Those confidence statements do not yet provide simultaneous validity over every stopping time. Part fifty-eight builds inference that stays valid however often you look, and lets you stop when you like.
Where it comes back. Part fifty-eight's e-values and test martingales. Part fifty-nine's conformal inference when p and n grow together. Part sixty-two's prediction intervals for individual causal effects. Part sixty-four's uncertainty for foundation models. And the predictive claims of the dissertation.
Six problems, with full solutions in the README. The lemma's exact coverage; the Beta law; the Bahadur–Savage bound; ACI's guarantee; Mondrian coverage; and conformal risk control. Pause here if you want to try them.
The books behind this part: Angelopoulos, Barber and Bates's theoretical foundations; Vovk, Gammerman and Shafer's original book; and Angelopoulos and Bates's gentle introduction; with the papers from Bahadur and Savage to Gibbs, Cherian and Candès.
Fifty-seven parts of sixty-five. In 1943 a Navy captain complained to the Statistical Research Group at Columbia that ordnance tests ran long after the answer was obvious, and Abraham Wald invented the sequential probability ratio test. Next, Part fifty-eight: anytime-valid inference and adaptive experiments.
Where it goes next. ACI's online-learning idea becomes anytime-valid testing with e-values in Part 58; conformal inference when p and n grow together is in Part 59; prediction intervals for individual causal effects in Part 62; uncertainty for foundation models in Part 64; the dissertation's predictive claims in Part 65.
Key results
The part's results in one place, for revision.
Try it
Lab 57 · No interval for the mean, an exact one for the next draw
On the mixture (1 - eps) N(0, 1) + eps at 3/eps, whose mean is 3 for every eps, measure the 95% t-interval's coverage of the mean against the Bahadur-Savage bound, and split conformal's coverage of the next draw against k/(n + 1) and the Beta law of coverage given the calibration set.
python -m videos.stats.labs 57
needs numpy, scipy, matplotlib · download lab57.py ·
source on GitHubt-interval covers the mean, eps = 0.3 95.0% bound 1 - (1 - eps)^n = 100.0%
t-interval covers the mean, eps = 0.1 90.5% bound 1 - (1 - eps)^n = 99.5%
t-interval covers the mean, eps = 0.03 78.8% bound 1 - (1 - eps)^n = 78.2%
t-interval covers the mean, eps = 0.01 39.7% bound 1 - (1 - eps)^n = 39.5%
t-interval covers the mean, eps = 0.003 13.9% bound 1 - (1 - eps)^n = 13.9%
t-interval covers the mean, eps = 0.001 5.1% bound 1 - (1 - eps)^n = 4.9%
split conformal covers the next draw, eps = 0.003 95.1% lemma k/(n + 1) = 39/41 = 95.1%
coverage given 100 calibration scores: mean 90.1% Beta(91, 10) mean 90.1%
its 5% quantile 84.9% Beta 84.8%
A rare far value carries the mean where no sample of fifty finds it, so the t-interval's coverage falls with eps; the next draw's rank among the calibration scores is uniform whatever the law, so conformal coverage is k/(n + 1), on average over calibration sets.
The code (72 lines; it asserts its own result)
"""Lab 57: break the t-interval with the Bahadur-Savage mixture, and check the quantile lemma on the same data."""
import numpy as np
from scipy import stats
from videos.coursekit import labs
from explainer.stats.kit import dfree
TITLE = "No interval for the mean, an exact one for the next draw"
GOAL = ("On the mixture (1 - eps) N(0, 1) + eps at 3/eps, whose mean is 3 for every eps, measure the 95% t-interval's "
"coverage of the mean against the Bahadur-Savage bound, and split conformal's coverage of the next draw "
"against k/(n + 1) and the Beta law of coverage given the calibration set.")
TASKS = [
"Raise n from 50 to 500 at eps = 0.003. Does the t-interval recover? Then shrink eps to 0.0003 and see the bound return.",
"Replace the mean by the median: cover the mixture's median with the order-statistic interval of Part 16 and check that its coverage does not depend on eps.",
"Call dfree.quantile_lemma_coverage(8, 0.1). Why does k = 9 with 8 calibration scores make the conformal interval the whole line, and what is the smallest n that gives a finite one?",
]
def run(seed=0):
rng = np.random.default_rng(seed)
n, alpha, shift = 50, 0.05, 3.0
lab = labs.Lab()
# 1. the t-interval for the mean: simulation against the bound
eps = np.array([0.3, 0.1, 0.03, 0.01, 0.003, 0.001])
sim = np.array([dfree.bahadur_savage_sim(n, e, rng, shift=shift, reps=6000) for e in eps])
upper = np.array([dfree.bahadur_savage_coverage(n, e, shift=shift)["upper"] for e in eps])
for e, s, u in zip(eps, sim, upper):
lab.row(f"t-interval covers the mean, eps = {e:g}", f"{s:.1%} bound 1 - (1 - eps)^n = {u:.1%}")
# 2. split conformal for the next draw from the same mixture: 10 points fix the centre, 40 calibrate
n_fit, n_cal, reps, e0 = 10, 40, 20000, 0.003
x = rng.standard_normal((reps, n + 1))
x[rng.random((reps, n + 1)) < e0] = shift / e0
centre = np.median(x[:, :n_fit], axis=1, keepdims=True)
scores = np.abs(x[:, n_fit:n] - centre)
lemma = dfree.quantile_lemma_coverage(n_cal, alpha)
q = np.sort(scores, axis=1)[:, lemma["k"] - 1]
conformal = np.mean(np.abs(x[:, n] - centre[:, 0]) <= q)
lab.row("split conformal covers the next draw, eps = 0.003", f"{conformal:.1%} lemma k/(n + 1) = {lemma['k']}/{n_cal + 1} = {lemma['exact']:.1%}")
# 3. coverage given the calibration set: Beta(k, n + 1 - k), here for |N(0, 1)| scores
law = dfree.conformal_coverage_law(100, 0.1)
cal = np.sort(np.abs(rng.standard_normal((4000, 100))), axis=1)[:, law["a"] - 1]
given = 2 * stats.norm.cdf(cal) - 1
lab.row("coverage given 100 calibration scores: mean", f"{given.mean():.1%} Beta({law['a']}, {law['b']}) mean {law['mean']:.1%}")
lab.row("its 5% quantile", f"{np.quantile(given, 0.05):.1%} Beta {law['q05']:.1%}")
lab.note = ("A rare far value carries the mean where no sample of fifty finds it, so the t-interval's coverage falls "
"with eps; the next draw's rank among the calibration scores is uniform whatever the law, so conformal "
"coverage is k/(n + 1), on average over calibration sets.")
assert np.all(sim <= upper + 0.02), "coverage never exceeds the Bahadur-Savage bound"
assert sim[0] > 0.9 and sim[4] < 0.2 and sim[5] < 0.09 and abs(sim[4] - upper[4]) < 0.03, "the t-interval collapses as eps falls"
assert abs(conformal - lemma["exact"]) < 0.008, "the quantile lemma's exact coverage"
assert abs(given.mean() - law["mean"]) < 0.004 and abs(np.quantile(given, 0.05) - law["q05"]) < 0.008, "the Beta law"
fig, ax = labs.figure(2, size=(11, 4.2))
ax[0].plot(eps, upper, color=labs.GOLD, label="Bahadur-Savage bound")
ax[0].plot(eps, sim, "o", color=labs.RED, label="t-interval for the mean (simulated)")
ax[0].axhline(0.95, color=labs.MUTED, ls="--", lw=1)
ax[0].plot([e0], [conformal], "s", color=labs.GREEN, label="split conformal for the next draw")
ax[0].set(title="n = 50, every mixture has mean 3", xlabel="eps, the weight of the far value (log scale)",
ylabel="coverage", xscale="log", ylim=(0, 1.02))
ax[0].legend(loc="lower right")
grid = np.linspace(0.78, 0.98, 300)
ax[1].hist(given, bins=40, density=True, color=labs.BLUE, alpha=0.6, label="4,000 calibration sets")
ax[1].plot(grid, stats.beta.pdf(grid, law["a"], law["b"]), color=labs.GOLD, label=f"Beta({law['a']}, {law['b']})")
ax[1].axvline(0.9, color=labs.MUTED, ls="--", lw=1, label="nominal 90%")
ax[1].set(title="Coverage given the calibration set, n = 100, alpha = 0.1", xlabel="coverage of the next draw", ylabel="density")
ax[1].legend(loc="upper left")
lab.fig = fig
return lab
Now change it
- Raise n from 50 to 500 at eps = 0.003. Does the t-interval recover? Then shrink eps to 0.0003 and see the bound return.
- Replace the mean by the median: cover the mixture's median with the order-statistic interval of Part 16 and check that its coverage does not depend on eps.
- Call dfree.quantile_lemma_coverage(8, 0.1). Why does k = 9 with 8 calibration scores make the conformal interval the whole line, and what is the smallest n that gives a finite one?
Problems, with solutions
Try each problem before opening its solution.
-
The lemma's exact coverage. Show that with \(n+1\) exchangeable almost surely distinct scores, \(P(S_{n+1} \le S_{(k)}) = k/(n+1)\) exactly.
Solution
With exchangeable, almost surely distinct scores S₁, …, S_{n+1}, assume scores are almost surely distinct (continuous marginals alone do not rule out dependent ties), so every ordering is equally likely, so the rank of S_{n+1} is uniform on {1, …, n + 1}. S_{n+1} ≤ S_(k) (the k-th smallest of the first n) exactly when its rank among all n + 1 is at most k, so P = k/(n + 1).
-
The Beta law. Show that the coverage of split conformal for IID continuous scores, given calibration, is Beta\((k, n + 1 - k)\).
Solution
Assume IID continuous scores, conditional on a separately trained fixed score function. Given the calibration scores, coverage is F(S_(k)). The F(S_i) are i.i.d. uniform, and F is increasing, so F(S_(k)) = U_(k), the k-th order statistic of n uniforms, which is Beta(k, n + 1 − k).
-
Bahadur–Savage. For the Bahadur–Savage family, show the \(t\)-interval's coverage is at most \(1-(1-\varepsilon)^n+(1-\varepsilon)^n c_n\), where \(c_n\) is the no-atom coverage.
Solution
Let c_n(M)=P(|T_{n−1}(−M√n)|≤t_{n−1,1−α/2}). On the no-atom event the sample is IID N(0,1), so coverage of the mixture mean M is at most 1−(1−ε)^n+(1−ε)^n c_n(M). At fixed n and M=3, sending ε→0 leaves the tiny positive c_n(3), about 4.928e−79 at n=50, rather than zero. For the general impossibility argument first let M grow to make c_n(M) arbitrarily small and then make ε small; the mixture still has a finite mean and finite variance for every member. The no-atom term uses a noncentral t distribution, not a normal approximation with a random denominator replaced by one.
-
ACI. Show that ACI's average miss rate satisfies \(|\bar e_T - \alpha| \le (\max(\alpha_1, 1 - \alpha_1) + \gamma)/(\gamma T)\).
Solution
Summing α_{t+1} = α_t + γ(α − err_t) gives α_{T+1} − α₁ = γ Σ(α − err_t). If α_t < 0 the set is the whole line and err_t = 0, so α_t rises; if α_t > 1 the set is empty and err_t = 1, so it falls; hence α_t ∈ [−γ, 1 + γ] for all t, and |Σ(α − err_t)| ≤ (max(α₁, 1 − α₁) + γ)/γ. Divide by T.
-
Mondrian. Show that Mondrian conformal gives coverage \(\ge 1 - \alpha\) within every group of a partition.
Solution
Conditional on the group g of the test point, the calibration points of group g and the test point are exchangeable (exchangeability is preserved by conditioning on a symmetric event), so the lemma applies within g.
-
Risk control. Prove conformal risk control: \(E L_{n+1}(\hat\lambda) \le \alpha\) for losses in \([0, B]\), nonincreasing in \(\lambda\).
Solution
Use a fixed ordered finite threshold grid with bounded nonincreasing losses and a feasible corrected-risk threshold; a continuous infimum additionally needs attainment/right-continuity. Let λ′ be the smallest grid value with Σ_{i≤n+1}L_i(λ)/(n+1)≤α, using the actual test loss. Since L_{n+1} ≤ B, λ′ ≤ λ̂, so L_{n+1}(λ̂) ≤ L_{n+1}(λ′) by monotonicity. By exchangeability E L_{n+1}(λ′) = E (1/(n + 1)) Σ L_i(λ′) ≤ α.
Notes and sources
Where it comes back
- Part 58: e-values and test martingales, and ACI's online-learning idea made into anytime-valid tests.
- Part 59: conformal inference when p and n grow together.
- Part 62: prediction intervals for individual causal effects.
- Part 64: uncertainty for foundation models.
- Part 65: the dissertation's predictive claims.
Glossary
- Foundations. Exchangeability; nonconformity score; rank; quantile lemma; calibration set; marginal coverage; training-conditional (PAC) coverage; smoothed p-value; tolerance interval.
- Methods. Full conformal; split conformal; jackknife; jackknife+; CV+; homotopy; algorithmic stability.
- Limits. Conditional coverage; local conformal; Bahadur–Savage family; impossibility; functional.
- Classes and weights. Mondrian conformal; group-conditional coverage; conditional calibration; slack; weighted conformal; covariate shift; label shift; likelihood ratio; nonexchangeable conformal; total variation.
- Online and testing. Adaptive conformal inference; DtACI; conformal p-value; PRDS; outlier detection.
- Risk. Conformal risk control; false negative rate; learn then test; conformal factuality.
Sources
- The hook. R. R. Bahadur & L. J. Savage, Ann. Math. Stat. 27 (1956); S. Wilks, Ann. Math. Stat. 12 (1941).
- Foundations. V. Vovk, A. Gammerman & G. Shafer, Algorithmic Learning in a Random World (2005; 2nd ed. 2022); V. Vovk, Proc. ACML (2012); J. Lei, M. G'Sell, A. Rinaldo, R. Tibshirani & L. Wasserman, JASA 113 (2018); A. Angelopoulos, R. Foygel Barber & S. Bates, Theoretical Foundations of Conformal Prediction (2024); A. Angelopoulos & S. Bates, A Gentle Introduction to Conformal Prediction (2021).
- Methods. R. Foygel Barber, E. Candès, A. Ramdas & R. Tibshirani, Ann. Stat. 49 (2021) (jackknife+); J. Lei, Biometrika 106 (2019); M. Bian & R. Foygel Barber, EJS 17 (2023).
- Impossibility. J. Lei & L. Wasserman, JRSS B 76 (2014); R. Foygel Barber, E. Candès, A. Ramdas & R. Tibshirani, Information and Inference 10 (2021); R. Foygel Barber, EJS 14 (2020); D. Donoho, Ann. Stat. 16 (1988).
- Function classes. I. Gibbs, J. Cherian & E. Candès, JRSS B (2025).
- Beyond exchangeability. R. Tibshirani, R. Foygel Barber, E. Candès & A. Ramdas, NeurIPS (2019); L. Lei & E. Candès, JRSS B 83 (2021); R. Foygel Barber, E. Candès, A. Ramdas & R. Tibshirani, Ann. Stat. 51 (2023); V. Chernozhukov, K. Wüthrich & Y. Zhu, COLT (2018).
- Online. I. Gibbs & E. Candès, NeurIPS (2021); I. Gibbs & E. Candès, JMLR 25 (2024).
- Outliers and risk. S. Bates, E. Candès, L. Lei, Y. Romano & M. Sesia, Ann. Stat. 51 (2023); A. Angelopoulos, S. Bates, A. Fisch, L. Lei & T. Schuster, ICLR (2024); A. Angelopoulos, S. Bates, E. Candès, M. Jordan & L. Lei, arXiv:2110.01052 (2021); C. Mohri & T. Hashimoto, ICML (2024).
- Efficiency. J. Lei, J. Robins & L. Wasserman, JASA 108 (2013).
- Data. CDC/NCHS, NHANES 2017–18; W. Wolberg, W. Street & O. Mangasarian (1995).
About this partfrom its README
Part 57 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 V, the research frontier.
It opens with Bahadur & Savage (1956), The nonexistence of certain statistical procedures. Over all distributions with a finite mean, no interval of bounded length covers the mean with probability bounded away from zero. A mixture with mean exactly 3, almost all of it N(0, 1), drives the 95% t-interval's coverage to 14% at n = 50, while split conformal's prediction interval for a new draw from the same mixture covers 95.8%. The part asks what can be promised without a parametric model, under explicit sampling assumptions, and maps the boundary between the possible and the impossible:
- the hook: Bahadur–Savage for intervals and for tests, the bound against simulation, Wilks's tolerance intervals (1941), and why the median survives;
- exchangeability and the quantile lemma: the rank strip, the exact coverage k/(n + 1), the Beta law under IID continuous scores of coverage given the calibration set (Vovk 2012) and PAC thresholds, ties and smoothed p-values, split conformal;
- full conformal, split conformal and jackknife+ (Barber, Candès, Ramdas & Tibshirani 2021): full against split on ridge regression, the lasso's homotopy (Lei 2019), the tournament proof of 1 − 2α, stability, CV+, the cost ledger;
- impossibility: conditional coverage forces infinite expected length (Vovk 2012; Lei & Wasserman 2014), local conformal by bins and its counted limit, length lower bounds for the relaxation (Barber et al. 2021), no distribution-free interval for P(Y = 1 | X = x) (Barber 2020);
- conditional guarantees over function classes (Gibbs, Cherian & Candès 2025): the shift view, the augmented quantile regression, the proof, computation by LP and bisection, the dimension/prevalence-dependent group slack, infinite penalized classes;
- beyond exchangeability: weighted conformal under covariate shift (Tibshirani, Foygel Barber, Candès & Ramdas 2019), estimated weights and individual treatment effects (Lei & Candès 2021), nonexchangeable conformal with fixed weights (Barber, Candès, Ramdas & Tibshirani 2023) and its total-variation bound, computed;
- online and adversarial coverage: adaptive conformal inference (Gibbs & Candès 2021), its two-line proof, the step size on a drifting series, the bound counted, DtACI;
- conformal p-values and outlier testing (Bates, Candès, Lei, Romano & Sesia 2023): PRDS, BH, the resolution limit 1/(n + 1), on the Wisconsin biopsies;
- risk control (Angelopoulos, Bates, Fisch, Lei & Schuster 2024): the proof, learn-then-test, multilabel screening, and conformal factuality for language models (Mohri & Hashimoto 2024);
- Mondrian and group-conditional coverage on NHANES 2017–18: ten overlapping age, sex and race groups;
- open problems, each with what is known, and a reader's checklist.
It keeps two promises:
- Part 34 built split conformal, CQR, Mondrian sets and ACI, and promised the theory. Chapters 1–7 prove it and push it to its limits.
- Part 16's distribution-free tests were about medians and ranks. Chapter 0 shows why the mean was never on offer.
Built in this part:
statkit.dfree(explainer/stats/kit/dfree.py), tested intests/test_stats_kit_dfree.py:- the Bahadur–Savage mixture: the t-interval's coverage bound and its simulation;
- the quantile lemma's exact coverage and the Beta law of coverage given the calibration set;
- full conformal for ridge regression on all residual-crossing breakpoints, retaining a union of accepted intervals;
- the jackknife and jackknife+ for any fitting routine, and the minimum-norm interpolator as an unstable one;
- binned conditional coverage and the group-conditional threshold of Gibbs, Cherian & Candès (quantile regression as an LP, bisection on the score);
- nonexchangeable conformal with fixed weights;
- conformal risk control for monotone losses;
- conformal outlier p-values.
- The rank strip (
RankStripinexplainer/stats/viz.py), the part's instrument: the n + 1 rank slots of the calibration scores and the test score, the covered slots up to k = ⌈(n + 1)(1 − α)⌉ and the missed ones above, withdrop(k)to land the test score in any slot. It shows why the lemma holds whatever the distribution.
Data.
- From the Museum: NHANES 2017–18 (systolic pressure, age, sex, race, BMI) and the Wisconsin breast cancer data.
- The rest is exact arithmetic or seeded simulation.
The Coverage Board gains six rows:
| Method | Setting | Nominal | Achieved | Verdict |
|---|---|---|---|---|
| t-interval for the mean | Bahadur–Savage mixture, n = 50 | 95% | 14.2% | broken |
| split conformal prediction interval | Bahadur–Savage mixture, n = 50 | 95% | 95.8% | kept |
| marginal split conformal, ages 70+ | NHANES systolic pressure | 90% | 78.3% | broken |
| group-conditional conformal, ages 70+ | NHANES systolic pressure | 90% | 90.7% | kept |
| split conformal after a changepoint | noise SD 1 → 2.5, 300 steps after | 90% | 75.7% | broken |
| weighted (nonexchangeable) conformal | noise SD 1 → 2.5, 300 steps after | 90% | 84.2% | broken |
Chapter notes
| # | Chapter | Numbers |
|---|---|---|
| 0 | Bahadur and Savage | n = 50, mixture mean 3: t-interval coverage 95% (ε = 0.3), 63.5% (0.02), 22.1% (0.005), 14.2% (0.003; bound 13.9%), 5.5% (0.001); P(no atom) = 0.997⁵⁰ = 0.861 |
| 1 | The quantile lemma | n = 19: k = 18, coverage 18/20; n = 20: 19/21 = 90.5%; finite only if n ≥ 9 at α = 0.1; n = 100: Beta(91, 10), mean 90.1%, SD 3.0, 5% quantile 84.8%, 5.9% of 4,000 calibration sets below 85%; PAC k = 96 |
| 2 | Full, split, jackknife+ | ridge, n = 40, p = 5, 200 reps: full 90.0% (median total set length 3.583), split 90.0% (4.04) |
| 3 | Impossibility | heteroscedastic regression: plain split 88.9% overall, 100% where the noise is small, 57% where it is large; normalized residuals 89.9%, 86–93% in every bin; 1,200 points allow at most 133 bins at α = 0.1 |
| 4 | Function classes | 11 basis columns, rank 9, n = 1,200: marginal upper slack ≤ 9/1,201; a group upper bound divides by its prevalence |
| 5 | Beyond exchangeability | jump in the noise SD at t = 1,000: equal weights 77% in the 300 steps after, ρ = 0.99 weights 86%; overall 87.3% vs 89.8%; TV bound 50 steps after: coverage ≥ 47% (equal) vs ≥ 60% (ρ = 0.99), swapped-pair TV 0.52 |
| 6 | Online | the same series: γ = 0 77% after the jump (miss rate 12.7%), γ = 0.005 89% (9.9%), γ = 0.02 90% (10.1%); 16 whole-line sets at γ=0.02; bound 181/T, within one point needs T ≥ 18,100 |
| 7 | Outliers | Wisconsin, 150 benign fit the score, 157 reference, 50 benign + 40 malignant tests, BH q = 0.1, 50 splits: FDR 5.6%, power 72.8%; pooled over 20 splits, 64% of malignant p ≤ 0.02 |
| 8 | Risk control | 20 candidate labels, n = 500, FNR at α = 0.1: λ̂ = 0.595, test FNR 8.9%, mean set size 8.2, mean FNR over 200 calibration sets 9.7%; n = 100 needs R̂ ≤ 9.1% |
| 9 | Groups | NHANES, 5,176 adults, 8 splits: marginal 89.5% overall, 98.6% (18–29), 78.3% (70+), 85.7% (race 4); Mondrian by age fixes ages only (race 4 86.0%); group-conditional 88.6–91.0% in every row |
| 10 | Open problems | — |
| 11 | Outro | — |
Companion material in this repository
The syllabus's plan for this partfrom SYLLABUS.md, the plan of record
- Hook: Bahadur & Savage (1956). The t-interval's coverage driven to near 0 over a heavy-tailed family (Board). Upgrade card from Part 34.
- Exchangeability and the quantile lemma, proved.
- Full, split and jackknife+ conformal; the jackknife+ proof (Barber et al. 2021).
- Impossibility. Conditional coverage (Vovk 2012; Lei & Wasserman 2014; Foygel Barber et al. 2021); distribution-free regression functionals (Barber 2020).
- Conditional guarantees over function classes (Gibbs, Cherian & Candès 2023).
- Beyond exchangeability. Weighted conformal; nonexchangeable data (Barber et al. 2023).
- Online and adversarial. Adaptive conformal inference and its guarantees (Gibbs & Candès 2021).
- Conformal p-values and outlier testing (Bates et al. 2023).
- Risk control (Angelopoulos et al.).
- Mondrian and group-conditional coverage (Board).
- Open problems.
Built: statkit.conformal (II). Books: Angelopoulos, Barber & Bates; Vovk, Gammerman & Shafer.
Build the film
python -m videos.stats.stats57.compute # the part's numbers, into .cache/stats57
python tools/build.py stats57 # render and assemble the film
EXPLAINER_TTS=silent python tools/qa_scene.py stats57 Hook # one chapter, silent, with a contact sheet
Scenes: videos/stats/stats57. 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.stats57.compute # once (about twenty-five minutes, mostly the NHANES LPs)
python tools/build.py stats57 -q l # fast 480p preview
python tools/build.py stats57 # 1080p30 -> renders/stats57.mp4
python tools/qa_scene.py stats57 Lemma
python tools/lecture_length.py stats57 --floor 50