Hero image: prefer a licensed (CC0 / public domain / CC BY / CC BY-SA) photograph of a boot heel with a pull tab (bootstrap).

The English pull tab on a boot heel is called a bootstrap; the method's English name is often linked to the saying about pulling oneself up by one's bootstraps. AI-generated schematic.

The bootstrap, proposed by Bradley Efron in 1979, treats the sample in hand as a stand-in for the population, repeatedly resamples with replacement and recomputes the statistic, and uses the distribution of those recomputed values to approximate the sampling distribution—thereby estimating standard errors and confidence intervals when no ready formula exists. This article covers the basic idea, algorithms for standard errors and intervals, the number of resamples, failure cases, and how the method differs from permutation tests, with a reproducible Python example.

Basic idea and procedure

The hard part of statistical inference is that we hold only one sample yet want to know how a statistic would fluctuate under repeated sampling. Efron (1979) framed the problem as: given a random sample from an unknown distribution F, estimate the sampling distribution of some random variable using only the observed data. His "bootstrap" performed well for the variance of the sample median, misclassification rates in linear discriminant analysis, ratio estimation, and regression parameters, among other examples; he also showed that the then-popular jackknife can be viewed as a linear approximation to the bootstrap. Ernst and Hutson (2003) summarize the method as essentially a plug-in procedure: replace unknown F with the empirical distribution F̂ (probability 1/n on each observation) and compute the desired quantity; only when that quantity has no closed form do we need resampling to approximate it.

In practice, imagine a lottery box: write each of the n observations on a slip, draw one, record it, put it back, and repeat until you have n draws—one bootstrap sample. Because draws are with replacement, some observations appear two or three times and others not at all; for large n, the chance that a given observation is missing from a bootstrap sample is about (1 − 1/n)ⁿ ≈ 37%. Recompute the statistic of interest on each bootstrap sample (mean, median, correlation, regression coefficient—any of these), repeat B times, and the distribution of the B recomputed values is the bootstrap distribution. The analogy is: population is to sample as sample is to bootstrap sample. If the sample adequately represents the population, fluctuation of bootstrap statistics around the sample statistic approximates fluctuation of the sample statistic around the population parameter.

Standard errors, confidence intervals, and the number of resamples

The standard error is direct: the standard deviation of the bootstrap distribution is the bootstrap SE of the statistic; SciPy's scipy.stats.bootstrap returns that as standard_error. This is especially useful for medians, trimmed means, correlations, and other statistics without simple SE formulas. Hesterberg (2015) notes that bootstrap distributions are inherently a bit narrow: for the mean, the empirical variance divides by n rather than n − 1, so the ideal bootstrap SE equals √((n − 1)/n) · s/√n, slightly smaller than the textbook s/√n, with a larger gap in small samples.

Confidence intervals can be built in several ways. The percentile method is most intuitive: a 95% interval takes the 2.5% and 97.5% quantiles of the bootstrap distribution. Hesterberg (2015) points out that its coverage is clearly short in small samples; for symmetric data it amounts to replacing the t critical value and sample SD s in a t interval with a z critical value and a slightly small σ̂. People often think the bootstrap suits small samples and classical methods suit large ones; for percentile intervals the reverse is true. Efron's (1987) BCa (bias-corrected and accelerated) interval still takes quantiles from the bootstrap distribution but adjusts which two: the bias-correction term uses the share of bootstrap replicates that do not exceed the sample statistic (median-sense bias); the acceleration constant reflects how the statistic's SE changes with the parameter, handling skewness. DiCiccio and Efron's (1996) survey frame the goal of such methods as improving the accuracy of the standard interval θ̂ ± z·σ̂ by an order of magnitude when they can be used routinely, and they compare BCa, bootstrap-t, ABC, and calibration. SciPy 1.18.0's bootstrap offers percentile, basic (reverse percentile), and BCa intervals, defaulting to BCa; the docs also note that percentile, though intuitive, is rarely preferred in practice.

The number of resamples B controls Monte Carlo error, not the information in the original sample. Efron and Tibshirani (1993, p. 52) suggest that B = 50 often suffices for standard errors and that more than 200 is rarely needed, while confidence intervals need much larger B (as cited by Ernst and Hutson 2003). Hesterberg (2015) re-estimates under the rule that statistical conclusions should depend on the data, not Monte Carlo noise: keeping Monte Carlo fluctuation of percentile endpoints within about 10% needs roughly 15,000 replicates; building a t interval from a bootstrap SE needs about 5,000. He recommends 10,000 routinely and more when results matter—far above early advice. SciPy's default is 9,999. Still, larger B only brings results closer to the "ideal" bootstrap distribution; it cannot fix a sample that is too small or unrepresentative.

Mouse survival-time example

The following uses mouse-experiment data from Efron and Tibshirani (1993). It is a small randomized experiment: of 16 mice, 7 received a treatment meant to prolong post-operative survival and 9 were controls; the recorded outcome is days survived after experimental surgery. The book's companion R package bootstrap (CRAN version 2019.6) includes the data; the treatment group is 94, 197, 16, 38, 99, 141, 23. For hand checking we look only at the treatment group: sample mean 608/7 ≈ 86.86 days, sample SD s ≈ 66.77, textbook SE s/√7 ≈ 25.24; under the plug-in principle the ideal bootstrap SE is σ̂/√7 ≈ 23.36 (σ̂ divides by n, equal to 25.24 × √(6/7)).

import numpy as np
import matplotlib.pyplot as plt
from scipy import stats

# Treatment-group survival times (days), Efron & Tibshirani (1993); R package `bootstrap`, dataset mouse.t
x = np.array([94, 197, 16, 38, 99, 141, 23])
n = x.size
B = 10_000
rng = np.random.default_rng(1979)

idx = rng.integers(0, n, size=(B, n))
resamples = x[idx]
boot_mean = resamples.mean(axis=1)
boot_median = np.median(resamples, axis=1)

print(f"sample mean            : {x.mean():.2f}")
print(f"textbook SE s/sqrt(n)  : {x.std(ddof=1) / np.sqrt(n):.2f}")
print(f"ideal bootstrap SE     : {x.std(ddof=0) / np.sqrt(n):.2f}")
print(f"bootstrap SE (mean)    : {boot_mean.std(ddof=1):.2f}")
print(f"bootstrap SE (median)  : {boot_median.std(ddof=1):.2f}")
print("95% percentile CI (manual):", np.percentile(boot_mean, [2.5, 97.5]).round(2))

# The rng keyword requires SciPy >= 1.15
for method in ("percentile", "BCa"):
    res = stats.bootstrap((x,), np.mean, n_resamples=B, method=method,
                          rng=np.random.default_rng(1979))
    ci = res.confidence_interval
    print(f"95% {method:<10} CI (SciPy): [{ci.low:.2f}, {ci.high:.2f}]")

fig, (ax1, ax2) = plt.subplots(1, 2, figsize=(10, 4))
ax1.hist(boot_mean, bins=40, color="steelblue", edgecolor="white")
ax1.axvline(x.mean(), color="red", linestyle="--", label="sample mean")
ax1.set(title="Bootstrap distribution of the mean", xlabel="days", ylabel="count")
ax1.legend()
values, counts = np.unique(boot_median, return_counts=True)
ax2.bar(values, counts, width=4, color="darkorange")
ax2.set(title="Bootstrap distribution of the median", xlabel="days", ylabel="count")
fig.tight_layout()
fig.savefig("bootstrap_hist.png", dpi=150)

The code first does resampling by hand: it draws a 10000 × 7 index array—10,000 rounds from the lottery box—then computes the mean and median each round; it then calls SciPy's bootstrap with the same seed for percentile and BCa intervals. After running, check by hand: the printed bootstrap SE for the mean should be near the ideal 23.36 above; with B = 10000, Monte Carlo error is usually only a fraction of a day; it is smaller than 25.24, which is the "narrowness" noted earlier. The median is more striking: with odd n = 7, each bootstrap median must be one of the seven original observations, so the bootstrap distribution lives on a few points whose shape depends on gaps between observations. Hesterberg (2015) notes that for small-sample medians the bootstrap distribution can differ sharply from the true sampling distribution. With only seven observations, both percentile and BCa intervals should be read cautiously; exact numbers vary slightly with the seed—use the run you obtain.

Failure cases and how permutation tests differ

One failure mode is statistics that depend on extremes. Hesterberg (2015) states flatly that the bootstrap cannot estimate the sampling distribution of the sample maximum max(x). The reason is clear: the chance a bootstrap sample contains the original maximum is 1 − (1 − 1/n)ⁿ ≈ 63% for large n, so more than half the bootstrap mass piles on one point, unlike the true sampling distribution of the sample maximum. For bounded populations (for example uniform), the sample maximum always lies below the upper bound, yet a bootstrap maximum can never exceed the original sample maximum, so that gap is invisible. Minima and extreme quantiles that hinge on a few edge observations raise similar concerns.

A second issue is small samples. The bootstrap only reuses existing information; it cannot invent more. When the sample is tiny, the empirical distribution is already a rough stand-in for the population. Hesterberg (2015) summarizes: bootstrap distributions tend to be narrow; percentile intervals undercover in small samples; for medians and other statistics that depend on few observations, bootstrap shape can diverge far from the true sampling distribution. In stratified or two-sample designs, narrowness depends on each stratum or group's own sample size, not the total; he notes a stratified survey with only two people per stratum whose bootstrap SE is about √(1/2) times the truth. In his simulations, bootstrap-t intervals performed well even in very small samples; BCa corrects for skewness and bias but not for narrowness.

A third issue is dependent data. Ordinary bootstraps assume i.i.d. observations; drawing with replacement one at a time breaks serial dependence in time series, and the SE is no longer trustworthy. Künsch (1989) extended the jackknife and bootstrap to general stationary sequences: instead of single observations, draw contiguous blocks of length l with replacement and concatenate them into a bootstrap sample, preserving within-block dependence—the block bootstrap; he illustrated with sunspot counts and simulations. Block length is a trade-off: too short fails to keep dependence; too long leaves too few blocks to draw. The same logic applies to cluster samples and repeated measures: the resampling unit should match how the data were generated.

The bootstrap and the permutation tests discussed elsewhere on this site both resample, but they answer different questions. A permutation test shuffles group labels under a null of "no treatment effect"—without replacement—and centers its reference distribution at zero to ask whether an observed difference is rare, yielding a p-value. The bootstrap assumes no null: it resamples with replacement within groups, centers on the observed statistic, and measures uncertainty of the estimate, yielding SEs and confidence intervals (Hesterberg, 2015). For a two-group comparison, a two-sample bootstrap resamples within each group and recomputes the mean difference; a permutation test pools the groups and reassigns labels. Hesterberg also notes that even for testing, pooling then sampling with replacement (a pooled bootstrap) is less accurate than a permutation test: if the data have three outliers, the permutation p-value reflects "there are three outliers in total," whereas a pooled bootstrap lets the outlier count vary randomly. In short, use a permutation test to ask whether there is a difference; use the bootstrap to ask how large the difference is and how precise the estimate is.

References

  1. Efron, B. (1979). Bootstrap Methods: Another Look at the Jackknife. The Annals of Statistics, 7(1), 1–26. https://doi.org/10.1214/aos/1176344552

  2. Efron, B. (1987). Better Bootstrap Confidence Intervals. Journal of the American Statistical Association, 82(397), 171–185. https://doi.org/10.1080/01621459.1987.10478410

  3. Efron, B., & Tibshirani, R. J. (1993). An Introduction to the Bootstrap. Chapman & Hall. https://doi.org/10.1007/978-1-4899-4541-9

  4. DiCiccio, T. J., & Efron, B. (1996). Bootstrap confidence intervals. Statistical Science, 11(3), 189–228. https://doi.org/10.1214/ss/1032280214

  5. Künsch, H. R. (1989). The Jackknife and the Bootstrap for General Stationary Observations. The Annals of Statistics, 17(3), 1217–1241. https://doi.org/10.1214/aos/1176347265

  6. Ernst, M. D., & Hutson, A. D. (2003). Utilizing a Quantile Function Approach to Obtain Exact Bootstrap Solutions. Statistical Science, 18(2), 231–240. https://doi.org/10.1214/ss/1063994978

  7. Hesterberg, T. C. (2015). What Teachers Should Know About the Bootstrap: Resampling in the Undergraduate Statistics Curriculum. The American Statistician, 69(4), 371–386. https://doi.org/10.1080/00031305.2015.1089789; preprint arXiv:1411.5279

  8. SciPy Developers. scipy.stats.bootstrap. SciPy v1.18.0 Manual. https://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.bootstrap.html

  9. Tibshirani, R., & Leisch, F. bootstrap: Functions for the Book "An Introduction to the Bootstrap" (R package version 2019.6). CRAN. https://cran.r-project.org/web/packages/bootstrap/refman/bootstrap.html

  10. Research Methods · Ritual can be imitated; understanding cannot be faked.

  11. Compiled and published by Scholay, the one-stop academic platform. If anything here infringes your rights, please let us know and we will take it down.

  12. Also published on EnterScholar, a community for scholars in the age of AI.