About Bootstrap Resampling

Bootstrap resampling is a powerful non-parametric technique for estimating the uncertainty of any statistic — mean, median, correlation, regression coefficient — without making assumptions about the underlying probability distribution. The idea, introduced by Bradley Efron in 1979, is elegantly simple: treat your observed sample as a stand-in for the population, then repeatedly draw new samples of the same size from it with replacement (so the same observation can appear multiple times). Computing your statistic on each of these "bootstrap resamples" builds up an empirical sampling distribution, from which confidence intervals follow directly.

In this simulator you choose a population distribution (normal, skewed, bimodal, uniform, or heavy-tailed), a sample size n, the number of bootstrap resamples B, a confidence level, and the statistic of interest (mean, median, standard deviation, quartiles, or IQR). After clicking Run, the canvas displays the original sample, the bootstrap distribution of the statistic, and the resulting percentile confidence interval, letting you explore how sample size, B, and distributional shape all affect interval width and coverage.

Frequently Asked Questions

What does "resampling with replacement" mean?

When drawing a bootstrap resample of size n from your original n observations, each draw is independent: an observation is picked at random, recorded, and returned to the pool before the next draw. This means any observation can appear 0, 1, 2, or more times in a single resample. On average, each resample contains about 63.2% unique observations (1 − 1/e), with the rest being duplicates. This replication mimics the variability you would see if you collected a fresh sample from the same population.

How many bootstrap resamples B are needed for accurate confidence intervals?

For the percentile bootstrap, B = 1000 is sufficient for 95% confidence intervals in most cases; B = 10,000 is recommended for 99% intervals or when studying tail quantiles. The standard error of the bootstrap CI endpoint scales as 1/√B, so going from 1000 to 10,000 resamples reduces endpoint noise by √10 ≈ 3.2 times. For publication-quality results with extreme percentiles, B = 100,000 is advisable.

What is the percentile bootstrap confidence interval method?

After computing the statistic θ̂* on each of B resamples, sort the B values. The percentile CI at confidence level 1 − α takes the α/2 quantile as the lower bound and the 1 − α/2 quantile as the upper bound. For a 95% CI from B = 1000 resamples, the bounds are the 25th and 975th sorted values. The method is justified because the bootstrap distribution of (θ̂* − θ̂) approximates the true sampling distribution of (θ̂ − θ).

When should I use bootstrap instead of standard parametric confidence intervals?

Bootstrap CI is preferable when: (1) the statistic has no simple closed-form standard error (e.g., the median, IQR, or a regression R²); (2) the population distribution is clearly non-normal or heavy-tailed; (3) the sample size is small, making asymptotic normality suspect; or (4) you want a "sanity check" on parametric results. The standard t-interval for the mean is reliable for n ≥ 30 under moderate departures from normality, but bootstrap is always valid under weaker assumptions.

What is the difference between the percentile bootstrap and the BCa bootstrap?

The percentile bootstrap can be biased or have incorrect coverage if the sampling distribution of θ̂ is skewed or if θ̂ is a biased estimator of θ. The bias-corrected and accelerated (BCa) method, also by Efron, adjusts the quantile levels used to extract the CI endpoints using a bias correction z₀ (based on how often θ̂* < θ̂) and an acceleration constant a (based on the jackknife influence values). BCa CIs have better theoretical coverage and are recommended for skewed statistics.

Does the bootstrap work for time series or correlated data?

Standard i.i.d. bootstrap fails for time series because it destroys temporal correlation. Instead, block bootstrap methods resample consecutive blocks of observations (e.g., blocks of 20 data points) to preserve autocorrelation structure. Common variants include the moving block bootstrap, circular block bootstrap, and stationary bootstrap (random block lengths from a geometric distribution). For spatial data, spatial bootstrap or subsampling procedures are needed.

What is the jackknife and how does it relate to bootstrap?

The jackknife (Quenouille, 1949; Tukey, 1958) estimates bias and variance by sequentially leaving out one observation at a time, computing the statistic on the n−1 remaining values, and averaging or differencing the results. It is computationally cheaper than bootstrap (only n resamples vs B) but is limited to smooth statistics: it fails for the median and quantiles because small perturbations do not change the rank-order statistic. The bootstrap subsumes the jackknife as a special case.

How does sample size n affect bootstrap CI width?

Bootstrap CI width scales approximately as 1/√n for statistics with finite variance (like the mean). Doubling sample size from 30 to 120 halves the CI width. For heavy-tailed distributions (Cauchy has no finite variance), this 1/√n scaling breaks down and bootstrap CIs can be inconsistent. The simulator lets you observe this directly: try n = 10 vs n = 100 with the Cauchy-like ("heavy") distribution and compare how the CI width changes.

Can bootstrap estimate the uncertainty of a machine learning model's accuracy?

Yes — this is one of bootstrap's most popular modern applications. To estimate the variance of cross-validation accuracy, the .632 bootstrap evaluates each bootstrap model on the out-of-bag observations (the ~37% not drawn), combining with the training accuracy: erroṙ = 0.368 × training_error + 0.632 × out-of-bag_error. The .632+ method further adjusts for overfitting. Scikit-learn and R's caret package offer bootstrap-based model evaluation.

What are the limitations of the bootstrap?

Bootstrap is inconsistent for statistics that depend on extreme order statistics (e.g., the sample maximum or minimum), because the maximum of a resample can never exceed the maximum of the original sample. It also requires that the original sample is representative of the population — if the sample has selection bias, the bootstrap CI inherits that bias. Finally, computational cost scales with B and n, which can be prohibitive for slow model fits or very large datasets without sub-sampling.

What is the "plug-in principle" that justifies bootstrap?

The plug-in principle says: estimate any population quantity by substituting the empirical distribution function F̂(x) — the step function that places mass 1/n at each observed value — for the true distribution F(x). Bootstrap sampling from the original data is equivalent to sampling from F̂. Any population quantity, whether a mean, a quantile, or a complex functional, can then be estimated by computing the same quantity under F̂, with uncertainty characterised by the variability across bootstrap resamples.

About this simulation

Bootstrap resampling estimates how much a statistic — a mean, median, or IQR — would vary across repeated data collection, using only the sample you already have. Instead of assuming a bell-shaped population, it draws many new samples with replacement from your data and recalculates the statistic each time, building an empirical distribution from which a confidence interval is read directly. Bradley Efron devised the method in 1979.

🔬 What it shows

Each run draws n points from a chosen population shape — Normal, Skewed, Bimodal, Uniform or Heavy-tailed — then resamples it B times to build a histogram of the statistic. The shaded percentile interval is compared against the population's true value to show whether it covers it.

🎮 How to use

Pick a Population distribution and Statistic (Mean, Median, Std deviation, quartiles or IQR), then set Sample size n, Bootstrap resamples B and Confidence level. Press ▶ Run Bootstrap to rebuild the distribution, or 🔀 New Sample for a fresh original sample.

💡 Did you know?

Efron named the method after "pulling yourself up by your bootstraps" — using only the data at hand to learn about your own estimate's uncertainty, with no assumption about the population's underlying shape.

Frequently asked questions

What does resampling "with replacement" actually mean?

Each bootstrap resample draws n values from the original sample one at a time, replacing each value before the next draw, so an observation may appear once, many times, or not at all — mimicking the variability of a fresh sample.

Why does the confidence interval sometimes miss the true value?

A 95% interval is expected to miss the true value in roughly one run out of twenty; press New Sample repeatedly to watch this happen — occasional misses are expected, not a fault of the method.

How many bootstrap resamples B do I need?

A few thousand resamples usually gives a stable percentile interval. Too few makes the edges noisy; higher confidence levels or statistics like the IQR benefit from a larger B for a smoother histogram.

Does the choice of statistic change how the bootstrap behaves?

Smooth statistics like the mean converge quickly. The median, quartiles and IQR depend on ordered values and often show blockier histograms and wider intervals, especially at small sample sizes.

Why does sample size n matter so much?

Larger samples represent the population more faithfully, so the bootstrap distribution narrows and the interval shrinks as n grows. With the Heavy-tailed option this narrowing is much weaker, since extreme values dominate the statistic.