What Is Bootstrapping in Statistics? A Plain-English Guide with Examples
Bootstrapping estimates how much a statistic would change from sample to sample, using only the one sample you have. You draw many new samples from your data with replacement, compute the statistic on each, and read the standard error or a confidence interval off the spread of the results. It needs no formula for the statistic, so it works for medians, ratios and other estimates where textbook formulas are missing or rest on shaky assumptions.
Last updated · by the simstat.com editorial team · How we write
The problem the bootstrap solves
Any number you calculate from a sample, such as a mean, a median or a correlation, would come out a little differently if you had drawn a different sample. The standard error measures how big that wobble is, and a confidence interval turns it into a range of plausible values. For a mean there is a textbook formula. For most other statistics the formula is complicated, depends on assumptions such as normality, or does not exist.
Bradley Efron’s answer, published in 1979, was to let the computer do the work (Efron, 1979). If you cannot draw fresh samples from the population, draw them from the next best thing: the sample itself.
The intuition: your sample stands in for the population
Imagine your data written on slips of paper in a hat. Draw one slip, note its value, put it back, and repeat until you have as many values as you started with. Because you replace each slip, some values appear twice or more and others not at all. That new set is a bootstrap sample, or resample. Compute your statistic on it and you have one bootstrap replicate.
Do this thousands of times and the replicates pile up into the bootstrap distribution. Its spread is an estimate of how much the statistic varies from sample to sample. Efron and Tibshirani (1993) call this the plug-in principle: wherever the theory needs the unknown population, plug in the sample’s own distribution instead.
The name comes from the phrase “pulling yourself up by your bootstraps”: the method seems to get something from nothing. It doesn’t. It gets an honest estimate of variability from the information already in the sample, which is why it can’t rescue a sample that is too small or unrepresentative.
The formula
Write the data as x = (x₁, …, xₙ) and the statistic as s(x). For b = 1, …, B, draw a resample x*ᵇ of size n with replacement and compute the replicate
The bootstrap standard error is the standard deviation of the B replicates (Efron and Tibshirani, 1993):
The simplest confidence interval, the percentile interval, takes the α/2 and 1 − α/2 quantiles of the replicates. For a 95% interval those are the 2.5th and 97.5th percentiles:
That is the whole method. Everything else in the bootstrap literature is about doing these steps more accurately.
A worked example
Efron and Tibshirani (1993) use survival times, in days, of seven mice that received a new treatment: 94, 197, 16, 38, 99, 141, 23. The sample mean is 608 / 7 = 86.86 days, and the usual standard error of a mean, s/√n, is 66.77 / √7 = 25.24. Seven values is a small sample, which makes it a good test case.
Worked example: bootstrapping the mean survival time
Here are the first three resamples drawn by our bootstrap code at seed 1979. Notice the repeated values: that is sampling with replacement at work.
| Resample | Values drawn | Mean |
|---|---|---|
| 1 | 23, 16, 141, 197, 197, 197, 197 | 138.29 |
| 2 | 23, 38, 16, 197, 197, 23, 38 | 76.00 |
| 3 | 23, 197, 141, 23, 141, 94, 23 | 91.71 |
Continuing to B = 10,000 resamples gives 10,000 replicate means. They range from 18.0 to 169.0, and their average is 86.92, almost exactly the sample mean (an estimated bias of 0.06 days).
- Bootstrap standard error: the standard deviation of the replicates is 23.26 days.
- 95% percentile interval: the 2.5th and 97.5th percentiles are 44.3 to 134.7 days.
- 95% BCa interval: 46.3 to 138.3 days (bias correction ẑ₀ = 0.020, acceleration â = 0.029).
These numbers are computed from the code behind our calculator every time this page is built, so they match the tool exactly. Paste the seven values into the calculator, choose the mean, 10,000 resamples and 95%, and enter seed 1979 to reproduce them.
Why is the bootstrap standard error (23.26) smaller than the formula’s 25.24? The bootstrap treats the sample as the population, so it uses the population-style variance with divisor n instead of n − 1. For the mean, that makes its target s/√n × √((n − 1)/n) = 23.36, and 23.26 is close to that. Hesterberg (2015) calls this the bootstrap’s “narrowness bias”: with very small samples, bootstrap standard errors and percentile intervals come out somewhat too narrow. With 7 values the shrinkage is 1 − √((n − 1)/n), about 7%; with 50 values it is about 1%.
Percentile or BCa?
The percentile interval is easy to explain, but it assumes the bootstrap distribution is centred on your estimate and has the same shape whatever the true value is. The BCa (bias-corrected and accelerated) interval of Efron and Tibshirani (1993) adjusts which percentiles you read off. A bias correction, ẑ₀, measures how far the replicates sit to one side of your estimate. An acceleration, â, measures how the spread changes with the value of the statistic, and is estimated with the jackknife.
For the mean of these seven mice, both corrections are small and the two intervals differ by a few days. They part company for skewed statistics such as standard deviations and ratios, and there BCa is usually the more accurate. Our calculator shows both side by side, and its explanation of when the two intervals differ gives the BCa formula.
How to report a bootstrap result
A reader should be able to tell what you resampled, how often, and which interval you used. For the example above:
Mean survival in the treatment group was 86.86 days (bootstrap SE 23.26; 95% BCa confidence interval 46.3 to 138.3 days; 10,000 bootstrap resamples, seed 1979).
Include:
- the statistic and its value in the original sample;
- the interval method (percentile, BCa or another) and the confidence level;
- the number of resamples B;
- the software or code, and the seed if you want the run to be repeatable;
- anything special about the resampling, such as resampling within groups.
Common mistakes
Expecting the bootstrap to fix a small sample. Resampling reuses the information you have. It cannot add information about values you never observed. Look at the median of the same seven mice: the sample median is 94.0, the 95% percentile interval is 23.0 to 141.0, and the BCa interval is 16.0 to 99.0. With an odd number of values, every resampled median is one of the original seven numbers, so the bootstrap distribution is lumpy. Hesterberg (2015, Section 3.3) notes that the ordinary bootstrap tends not to work well for medians and other quantiles in small samples. When two reasonable methods disagree this much, the honest conclusion is that the sample is too small to pin the median down.
Using too few resamples. A few hundred resamples can be enough for a rough standard error, and Efron and Tibshirani (1993) note that B = 200 is rarely exceeded for that purpose. Interval endpoints sit in the tails of the distribution, so they need far more. Hesterberg (2015) recommends around 10,000 resamples for routine use. Rerunning with a different seed is a quick check: if the interval moves noticeably, increase B.
Resampling data that are not independent. The basic bootstrap assumes your observations are independent draws. Time series, repeated measures and clustered data need resampling schemes that keep the dependence intact, such as resampling whole clusters or blocks of consecutive observations (Davison and Hinkley, 1997).
Bootstrapping extremes. Statistics that depend on one or two observations, such as the sample maximum, behave badly under the bootstrap, because a resample can never contain a value larger than the largest one you saw. Efron and Tibshirani (1993) give the maximum as an example of the bootstrap failing.
Confusing the bootstrap with a permutation test. Both resample, but they answer different questions. The bootstrap estimates the variability of a statistic, which gives standard errors and confidence intervals. A permutation test shuffles group labels to ask whether an observed difference could be chance, which gives a p-value. Hesterberg (2015) discusses both. For the second question, read our guide to permutation tests or go straight to the permutation test tool.
Not saying which interval you used. “Bootstrap confidence interval” can mean several different methods that give different answers, as the median example shows. Always name the method.
Where to go next
The resampling hub collects our tools and guides on simulation-based methods. If you want the formula-based view of standard errors and confidence intervals first, start with the statistics hub. The textbook treatment remains Efron and Tibshirani (1993); Davison and Hinkley (1997) go further into dependent data and regression.
References
- Efron, B. & Tibshirani, R. J. (1993). An Introduction to the Bootstrap. Chapman & Hall/CRC.
- Efron, B. (1979). Bootstrap Methods: Another Look at the Jackknife. The Annals of Statistics, 7(1), 1–26.
- Hesterberg, T. C. (2015). What Teachers Should Know About the Bootstrap: Resampling in the Undergraduate Statistics Curriculum. The American Statistician, 69(4), 371–386 (doi:10.1080/00031305.2015.1089789; open access at PubMed Central).
- Davison, A. C. & Hinkley, D. V. (1997). Bootstrap Methods and their Application. Cambridge University Press.
Try it
- Bootstrap confidence interval: Resample your data to get percentile and BCa confidence intervals for a mean, median or standard deviation.
- Permutation test: Test a difference in means or medians between two groups by shuffling group labels, exactly or by simulation.