What “95% confident” promises and what it does not. Watch a hundred intervals try to catch the truth, see why small samples need Student’s t, and pull yourself up by the bootstrap
An estimate without an error bar is half a sentence. A confidence interval is the other half, and the word “confidence” has a precise meaning that is easier to see than to say: it is a promise about the method, kept over many repetitions, and not a statement about any one interval.
Press Step to watch one interval being built, then × 1,000 and read the count of hits. Change the confidence level and the sample size, press Find a miss, and then Hide the truth to see what a statistician actually has.
Slate-white: the population and its true mean μ (dashed), which the method never sees. Teal: one sample. Amber: the sample mean x̄ and the margin built around it. Each bar in the stack is one sample’s interval, emerald if it contains μ and rose if it does not; click a bar to inspect it. Changing the confidence level or the method re-judges the same samples, so you can watch the same bars stretch and change colour. Changing the population or n draws 100 new samples. The amber marker at the bottom is the share of hits so far, with a 95% Wilson band for the long-run rate.
Jerzy Neyman introduced confidence intervals in 1937. In his account the parameter μ is a fixed number, unknown but not random. What is random is the sample, and therefore the interval computed from it. A 95% confidence procedure is a recipe which, applied to sample after sample, produces intervals of which 95% contain μ. The 95% describes the recipe’s hit rate over repeated samples.
Once a particular sample is in hand and the endpoints are numbers, nothing random is left. That interval either contains μ or it does not, and “there is a 95% probability that μ lies between 9.1 and 11.4” is not what the method claims. The honest reading is: this interval came from a procedure that succeeds 95% of the time, and there is no way to tell from the interval alone whether this is one of the successes.
For a mean the interval is x̄ ± (multiplier) × (standard error), and with σ known its half-width is z*σ/√n. That formula holds the trade-off. More confidence means a larger multiplier and a wider interval: 1.28 for 80%, 1.96 for 95%, 2.58 for 99%. A larger sample narrows it, but only like 1/√n, so halving the width takes four times the data. The sample size changes the width and leaves the hit rate where it was.
A Bayesian credible interval does make a probability statement about the parameter given the data. The price is a prior distribution for the parameter, which has to be supplied in addition to the data. See also Bayesian Statistics.
Slide the sample size down to 5, then 2, and watch the amber pile grow tails that the dashed normal curve does not have, while the rose coverage curve sags below 95%. Then switch the population to skewed.
| n | 2 | 3 | 4 | 5 | 6 | 8 | 10 | 15 | 20 | 30 | ∞ |
|---|---|---|---|---|---|---|---|---|---|---|---|
| t* | 12.71 | 4.30 | 3.18 | 2.78 | 2.57 | 2.36 | 2.26 | 2.14 | 2.09 | 2.05 | 1.96 |
Top: each amber block is one sample reduced to the statistic (x̄ − μ)/(s/√n); values beyond ±6 are counted but fall off the edge of the chart. Rose shading is the area of the t curve beyond ±1.96. Bottom: for every n from 2 to 30, the share of 4,000 simulated intervals that contained μ, using 1.96 (rose) and using t* (emerald); the dotted line is the exact value for normal data, and the highlighted column is the n on the slider.
Real data: the example in Student’s 1908 paper, from measurements by Cushny and Peebles (1905). Teal: the ten differences. Amber: their mean and the 95% t interval, x̄ ± 2.26 × 0.389. Rose: the shorter interval that 1.96 would give, which claims more precision than ten patients can supply. Here the truth is not known, so the bar cannot be coloured as a hit or a miss.
William Sealy Gosset was a chemist and brewer at Guinness in Dublin, where experiments on barley and malt came in small samples. Guinness did not allow its employees to publish under their own names, so “The Probable Error of a Mean” appeared in Biometrika in 1908 under the pseudonym “Student”. He found the distribution partly by simulation, drawing samples by hand from cards of measurements, much as the demo does. R. A. Fisher supplied the rigorous derivation and the modern form of t in the 1920s.
The problem is that σ is almost never known. Replacing it by the sample’s s makes the statistic (x̄ − μ)/(s/√n) a ratio of two random quantities, and when s happens to come out small the ratio is large. For normal data this ratio follows the t distribution with n − 1 degrees of freedom, which has heavier tails than the normal curve. With n = 5 about 12% of its area lies beyond ±1.96, so the interval x̄ ± 1.96 s/√n covers only about 88% of the time; with n = 2 it covers about 70%. The cure is to use the wider multiplier t* in place of 1.96: 12.71 for n = 2, 2.78 for n = 5, 2.26 for n = 10, falling towards 1.96 as n grows.
The example is the one in Student’s paper: the extra sleep of ten patients on two drugs. The ten differences have mean 1.58 hours and t = 4.06 on 9 degrees of freedom, and the 95% interval runs from 0.70 to 2.46 hours.
The t interval is exact when the data are normal and holds up well under moderate departures from normality. Strong skewness at small n is its weak point: the interval then misses more often than promised, and mostly on one side.
Press Step to draw one resample, then Fill to 10,000 and read the middle 95% of the pile. Drag a dot out to make an outlier, reveal the population, and try the maximum of the uniform sample, where the method fails.
Teal: the sample in hand (left) and one resample of it (right), where a dot drawn several times grows and a dot never drawn turns grey. Amber: the statistic, and the pile of its values over all the resamples; bars beyond the middle 95% are greyed. Slate-white, once revealed: the population, its true value, and the statistic’s real sampling distribution from 4,000 fresh samples. The simulated samples are drawn from a skewed population, a uniform one on 0 to 20, or pairs with correlation 0.6; Anscombe’s set I is real data. Dragging a dot restarts the resampling. The coverage check draws fresh samples from the population and ignores any dots you have moved.
A median, a trimmed mean or a correlation has no formula as simple as s/√n for its standard error. Bradley Efron’s answer, in “Bootstrap Methods: Another Look at the Jackknife” (Annals of Statistics, 1979), was to let the sample stand in for the population. Draw n values from the sample with replacement, compute the statistic, and repeat thousands of times; the spread of those values estimates how the statistic would vary from one real sample to the next. The name comes from the phrase about pulling oneself up by one’s own bootstraps. Because the draws are with replacement, each resample leaves out a share (1 − 1/n)n of the points on average, which is close to 1/e, about 36.8%.
The bootstrap estimates the spread of a statistic well. It cannot manufacture information the sample lacks: the pile is centred on the sample’s own value, not on the truth, and a small or unrepresentative sample gives a poor stand-in for the population. It also fails outright for some statistics. The sample maximum is the standard counterexample, because no resample can contain a value larger than the largest one observed.
The percentile interval, the middle 95% of the bootstrap values, is the simplest of several bootstrap intervals. For small samples it tends to cover somewhat less often than promised, as the coverage check shows; refinements such as the BCa and bootstrap-t intervals usually do better.
Formulas can mislead too. For a proportion, the textbook Wald interval p̂ ± 1.96 √(p̂(1 − p̂)/n) covers poorly when n is small or p is near 0 or 1. With n = 20 its true coverage falls below 90% for many values of p, and to about 64% at p = 0.05. The interval Edwin Wilson proposed in 1927 stays above 92% across p from 0.05 to 0.95 at the same n, and Brown, Cai and DasGupta (2001) recommended it over Wald.
Spot a mistake or have an idea?