Interactive statistics

56 free interactive lessons: from mean and median to A/B tests and Bayes. Drag the charts and build intuition. No sign-up.

Module 4: From sample to world

The bootstrap: an interval without formulas

We built the confidence interval leaning on formulas and normality. But what if the data is odd and no suitable formula is at hand? There is an ingeniously simple trick โ€” the bootstrap: resample the sample from itself.

the original sample (right-skewed) โ€” we draw n values from it with replacementsample mean 38.0this resampleโ€™s mean = 44.5 โ€” drops below โ†“distribution of many resamplesโ€™ means โ†’ a bell
Resamples: 1
โ— resample values / latest meanโ–ฎ accumulated meansโ–ฎ 95% bounds
The algorithm: 1) draw n values from the sample with replacement (green dots above) ยท 2) compute their mean (the green dot) ยท 3) it drops into the bottom distribution ยท repeat N times.

On top is our only sample of 15 values (right-skewed). The bootstrap works in steps: 1) draw the same number of values from it randomly WITH REPLACEMENT (one value may appear several times, another not at all), 2) compute their mean, 3) drop that mean into the bottom distribution. Press "1 resample (step)" โ€” green points of the drawn values pour in on top, their green mean appears, and via the diagonal link it "falls" into the bottom histogram.

What it means

The bootstrap is the workhorse when formulas are missing or data is non-normal: a confidence interval for median revenue, for conversion at small counts, for any custom dashboard metric.

The same principle underlies many machine-learning methods (bagging, random forests): train models on resampled datasets and average.

Where it shows up

An analyst needs to know how reliable the median call duration is โ€” the formulas for the median are unwieldy, while the bootstrap gives an interval in a couple of lines of code.

In science the bootstrap saves the day when the distribution is unknown: instead of dubious assumptions, the data "tells its own story" about its variability.

The name comes from "pulling yourself up by your bootstraps" (Baron Munchausen pulled himself by the hair): Bradley Efron proposed exactly that in 1979 โ€” the sample pulls the estimate of its own uncertainty out of itself, with no new data.

Definitions
Bootstrap
estimating uncertainty by repeatedly recomposing the sample from itself.
Resampling with replacement
draw n values from the sample, returning each drawn value โ€” values may repeat.
Percentile interval
a confidence interval as the 2.5th and 97.5th percentiles of the bootstrap distribution.
When the method lies (assumptions)

The bootstrap recomposes what is already in the sample: if 30 observations failed to catch the distribution's tail, it will not appear in 10,000 pseudo-samples either. On small n the intervals come out too narrow โ€” optimistic.

The classic bootstrap requires independent observations: time series and clusters need special variants (block, cluster bootstrap). And for extreme statistics โ€” the maximum, the minimum, rare quantiles โ€” it is unreliable in principle.

Next โ†’
Enjoying the materials?

This site is built by the DataSlice Telegram channel: data analytics in plain words โ€” real cases, metrics, careers. The channel is in Russian.

Open the Telegram channel