Bell Statistics

What is the bootstrap?

The bootstrap estimates uncertainty by resampling your data with replacement thousands of times and watching how much the statistic moves. It replaces a formula for the standard error with simulation, which is what makes it work for quantities that have no convenient formula.

Also called
bootstrapping, resampling, percentile bootstrap, bootstrap confidence interval
Allon Korem

Written by Allon Korem

Chief Executive Officer

Last updated

In plain English

Every confidence interval rests on knowing how much a statistic would vary if you could repeat the experiment. For a mean there is a tidy formula for that variation. For a median, a 95th percentile, a ratio of two sums, or the difference between two conversion rates weighted by segment, there often is not — or the formula exists and depends on assumptions the data plainly violates. The bootstrap sidesteps the problem by simulating the repetition instead of deriving it.

The procedure is almost suspiciously simple. Take your sample of n observations and draw a new sample of size n from it, with replacement — so some observations appear twice or three times and others not at all. Compute your statistic on that resample. Do it ten thousand times. The spread of those ten thousand values is an estimate of how much your statistic bounces around, and the 2.5th and 97.5th percentiles of them form a 95% interval directly. No distributional assumption is made anywhere.

The logic is that your sample is the best available stand-in for the population. Drawing from it with replacement mimics drawing fresh samples from the population, and the variability you see across resamples approximates the variability you would have seen across real repetitions. That is also the source of its main limitation: if the sample is unrepresentative, the bootstrap faithfully reproduces the uncertainty of an unrepresentative sample. It quantifies sampling variability and is completely blind to selection bias.

In experimentation the cases where it earns its place are specific. Ratio metrics where the denominator is itself random — clicks per session, revenue per order — have a standard error that the naive formula gets wrong, and the alternatives are the delta method or the bootstrap. Percentile metrics such as p95 latency have no simple formula at all. And any metric where the analysis unit differs from the randomisation unit needs a cluster bootstrap, resampling whole users rather than individual events, or the interval will be far too narrow.

Two practical notes. Ten thousand resamples is a reasonable default; a thousand is enough for a standard error and too few for a stable 95% interval, since the tails are estimated from the extreme few. And the simple percentile interval is not always the best one — the bias-corrected and accelerated (BCa) variant adjusts for skew in the resampling distribution and is worth the extra computation for anything asymmetric, which most revenue metrics are.

The formula

There is no closed form, which is the point. What follows is the procedure and the two ways of turning the resampling distribution into an interval.

The procedure
for b = 1..B: sample n observations with replacement, compute θ̂*ᵇ

B is typically 10,000. Each resample is the same size as the original, which is what preserves the sampling variability being estimated.

Bootstrap standard error
SE = √( Σ ( θ̂*ᵇ − θ̄* )² / ( B − 1 ) )

The standard deviation of the resampled statistics. Directly comparable to an analytic standard error.

Percentile interval
( θ̂*₍₀.₀₂₅₎ , θ̂*₍₀.₉₇₅₎ )

Read the 2.5th and 97.5th percentiles off the resampling distribution. Needs B in the thousands to be stable in the tails.

Cluster bootstrap
resample USERS, keep all of each user's events

Required whenever the analysis unit is finer than the randomisation unit. Resampling events instead understates the interval, often badly.

Worked example

A marketplace wants a confidence interval on the change in 95th-percentile page load time between two variants, measured over 240,000 page views from 41,000 users. There is no standard formula for the standard error of a difference in percentiles, and page views from one user are highly correlated with each other.

Control p95
1,840 ms
Variant p95
1,712 ms
Observed difference
−128 ms
Resamples
10,000, clustered by user
Percentile interval
−201 ms to −54 ms
Naive event-level bootstrap
−149 ms to −107 ms

The variant is faster at the tail by 128 ms, with a plausible range of 54 to 201 ms once the clustering is respected.

The two intervals in the table are the finding. Resampling individual page views gives a range 3.5 times narrower than resampling users, and it is wrong — 41,000 users is the amount of independent information here, not 240,000 page views, and treating correlated events as independent manufactures precision that does not exist. A team reading the naive interval would conclude the improvement is pinned down to within ±21 ms; the honest answer is ±74 ms. This is the most common bootstrap mistake in web analytics and it is invisible, because the naive version runs happily and produces a tighter, more satisfying number. The rule is to resample at the level randomisation happened.

Common misconceptions

The bootstrap creates extra data, so it works around a small sample.
It creates no information at all. Every resample is drawn from the same n observations, and the interval it produces reflects how uncertain those n observations leave you. With a genuinely small sample the bootstrap correctly returns a wide interval — it makes the uncertainty visible rather than reducing it.
Because it makes no distributional assumptions, the bootstrap is assumption-free.
It drops the assumption about the shape of the sampling distribution and keeps the more important one: that your sample represents the population. It also assumes the observations you resample are independent, which is why resampling page views rather than users is a real error. A biased sample bootstraps into a confidently wrong interval.
A thousand resamples is plenty.
It is fine for a standard error and marginal for a 95% interval, whose endpoints are estimated from roughly the most extreme 25 values on each side. Ten thousand is a sensible default and costs seconds on any modern machine. If two runs of the same bootstrap give visibly different interval endpoints, B is too low.

Frequently asked questions

How many bootstrap resamples should I run?
Ten thousand is a good default for confidence intervals. A thousand suffices if you only want a standard error, but interval endpoints depend on the tails of the resampling distribution and those need far more samples to stabilise. The practical check is to run the whole procedure twice with different seeds: if the endpoints move by an amount you would care about, increase B.
Why does the bootstrap help with ratio metrics?
Because a ratio like clicks per session has a random denominator, and the usual standard error formula assumes it is fixed. That understates the true variability, sometimes substantially. The bootstrap resamples the underlying units and recomputes the whole ratio each time, so the denominator varies exactly as it does in reality. The delta method is the analytic alternative and is faster, at the cost of an approximation the bootstrap does not need.
What is a cluster bootstrap and when do I need one?
It resamples whole randomisation units — users, or markets — keeping all of that unit's observations together, rather than resampling individual events. You need it whenever one user contributes many rows, which is most web analytics. Resampling events treats correlated observations as independent and produces intervals that can easily be several times too narrow, with nothing in the output indicating a problem.
Should I bootstrap instead of running a t-test?
Usually not, for a simple comparison of two means. The t-test is fast, well understood, and at experiment sample sizes gives essentially the same answer. The bootstrap earns its place where no clean formula exists — medians, percentiles, ratios with random denominators, or any custom metric your team invented. Using it everywhere adds computation and a random seed to results that did not need either.

Related terms

  • Confidence interval

    The range your data can actually support, and why it answers the business question a p-value cannot.

  • Log-rank test

    For questions about when rather than whether — and it uses the people who have not converted yet instead of discarding them.

  • Mann-Whitney U test

    Compares by rank instead of by mean, so one whale cannot move the result — and answers a subtly different question.

  • Standard error

    How much your estimate would move if you ran the study again — precision, not spread.

  • Delta method

    The standard error for metrics that are functions of other metrics — and the covariance term everyone forgets.

  • Ratio metric

    When the denominator is random too, the ordinary standard error is wrong — and the interval it produces is too narrow.

Calculate it

  • Two-sample t-test

    Compare the average of two independent groups — plan the sample size, then test the result.

  • Proportion confidence interval

    A defensible interval around one rate — Wilson, Agresti-Coull, Jeffreys and Clopper-Pearson, side by side.

Knowing the term is the easy part

Applying it to a live measurement problem is the part that goes wrong. If you are designing an experiment, reading a result you do not trust, or trying to work out what your marketing actually caused, that is the work we do.