The idea
Classical inference hands you standard-error formulas for a few blessed statistics — means, proportions, regression coefficients. The moment you care about a median, a ratio of two metrics, an AUC, or a p90, the formula book runs out. The bootstrap replaces the formula book with compute:
- From your sample of observations, draw observations with replacement (some rows repeat, others drop out).
- Compute your statistic on the resample.
- Repeat times ( to ). The distribution of the values approximates the sampling distribution of the statistic.
From there: the SD of the values is the bootstrap standard error; the 2.5th and 97.5th percentiles form the 95% percentile interval.
Why this is legitimate and not a free lunch: the plug-in principle. The true sampling distribution comes from repeatedly sampling the population; we cannot do that, so we substitute the best available estimate of the population — the empirical distribution of the sample itself — and sample from that instead. The approximation is good exactly to the extent that the sample resembles the population. The bootstrap quantifies uncertainty; it manufactures no new information, and it faithfully reproduces any bias your sample already has.
A detail interviewers probe: resamples must be size , with replacement. Sampling noise depends on , so simulating at a different size measures the wrong thing — and without replacement at size you would get the original sample back every time, showing zero variance. Each resample leaves out about of observations — the same "out-of-bag" fraction that bagging exploits for free validation.
Its cousin, the permutation test, shuffles group labels instead: it simulates the null world ("labels do not matter") to get a p-value, whereas the bootstrap simulates the sampling process to get SEs and CIs. Both are "resampling methods"; they answer different questions.
Worked example
Ten measured API latencies (ms), sorted:
Sample median ms. The 350 is real (a retry storm), so you want the median and honest uncertainty — but there is no formula for medians.
Bootstrap by hand for two resamples (indices drawn with replacement):
| Resample (values drawn) | Median |
|---|---|
| 15, 15, 21, 30, 45, 45, 62, 80, 110, 350 | 45 |
| 12, 21, 30, 30, 51, 62, 62, 80, 110, 110 | 56.5 |
Run of these and collect the medians. A typical run concentrates on the achievable values (30, 37.5, 45, 48, 51, 56.5, 62, ...) with a 95% percentile interval of roughly ms. Notice what the bootstrap did automatically: the interval is asymmetric — wider above than below — because the data is right-skewed, something symmetry could never express. Also visible: with the bootstrap distribution is lumpy (medians of resamples can only hit averages of pairs of observed values) — a candid illustration that the bootstrap cannot conjure resolution the sample does not contain.
Cheat sheet
- Procedure: resample with replacement → recompute statistic → repeat → SE = SD of replicates; 95% CI = 2.5th-97.5th percentiles.
- Plug-in principle: empirical distribution stands in for the population; quality of the stand-in bounds quality of everything downstream.
- Out-of-bag fraction: each resample omits of rows.
- Percentile CI is the default; BCa (bias-corrected accelerated) improves coverage for skewed statistics at no conceptual cost.
| Use bootstrap for | Avoid / adapt for |
|---|---|
| medians, quantiles (central) | extreme order statistics: min, max, p99.9 |
| ratios (revenue per session, CTR per user) | time series → block bootstrap |
| correlation, AUC, F1, model metrics | clustered data → resample clusters/users, not rows |
| skewed metrics at moderate | tiny — empirical distribution too coarse |
| SE when no formula exists | biased samples — bootstrap inherits the bias |
Gotchas:
- Resample the randomization unit (user), not the row (event/session), when rows are dependent.
- only controls simulation noise; the original controls real precision. on is still an answer.
- Bootstrap ≠ permutation: bootstrap → CI/SE around an estimate; permutation → p-value under a no-effect null.
- For plain means at large , bootstrap and CLT formulas agree — use the formula; bootstrap earns its cost on everything else.