When there is no formula for a standard error, simulate one from the data you have. The bootstrap resamples the observed sample with replacement, recomputes the statistic each time, and reads its uncertainty off the spread: SEs and confidence intervals for medians, trimmed means, ratios, robust aggregates of benchmark scores, anything. You will learn percentile and basic intervals, why bootstrap samples contain about 63% of the data, stratified and block bootstraps for structured and correlated data, where the bootstrap fails (maxima, tiny samples), and its relatives: the jackknife, cross-validation and bagging.
★☆☆☆☆ Introductory⏱ 5 minGeneral audience. No mathematics required.
Making more experiments out of one
You timed a robot 40 times and found a median of 2.7 minutes. How precise is that median? Ideally you’d repeat the whole 40-run experiment many times and see how much the median moves. You can’t afford that. The bootstrap pretends your 40 runs are the population. It draws 40 runs from them at random, with repeats allowed, computes the median, and does that a thousand times. The spread of those medians estimates how much your real median would wobble.
It sounds like cheating, but it works remarkably well for most statistics, and it needs no formula at all.
Pull yourself up by your bootstraps: resample the data you have
statistic:
observed median 2.646 · bootstrap SE 0.250 (true SE 0.374) · 95% percentile CI [2.103, 3.011]
Orange: the bootstrap distribution, from 1500 resamples of the one observed sample. Grey dashed: the true sampling distribution from fresh samples, which you normally can't see. Green: the observed statistic. Shaded: the percentile interval. For smooth statistics (mean, median, trimmed mean) the bootstrap spread tracks the truth with no formula needed. For the max it piles up at the observed value (about 63%) and can't see beyond it: the bootstrap fails for extremes.
Why engineers care
Uncertainty for a median latency, a 95th-percentile error, a ratio of two rates, an interquartile-mean score across RL tasks, or a model’s accuracy on a test set: most real statistics have no textbook SE. The bootstrap gives one in a few lines of code.
📝 Quick check (Level 0)
0/3 answered
1. A bootstrap resample is drawn…
2. The spread of bootstrap statistics estimates…
3. Does the bootstrap need a formula for the SE?
Level 1: Beginner
★★☆☆☆ Basic⏱ 20 minSecondary-school mathematics: arithmetic and elementary algebra.
The plug-in principle
The unknown population distribution F is replaced by the empirical distribution F^n, which puts mass 1/n on each observation. Sampling from F^n means resampling the data with replacement (Efron, 1979).
Algorithm:
For b=1,…,B, draw x∗b by resampling n points with replacement, and compute θ^∗b=T(x∗b).
SE:SE=sd(θ^∗1,…,θ^∗B).
Percentile CI: the α/2 and 1−α/2 quantiles of the θ^∗.
Use B≈1000–5000 for intervals. A few hundred is enough for an SE.
Facts worth knowing
Each resample contains about 1−(1−1/n)n→1−1/e≈63.2% of the distinct original points. The remainder are “out-of-bag”.
For the mean, the bootstrap SE is ≈s/n, so it agrees with theory where theory exists.
📝 Quick check (Level 1)
0/3 answered
1. About what fraction of original points appear in a bootstrap sample?
2. The percentile interval uses…
3. The bootstrap replaces F with…
Level 2: Intermediate
★★★☆☆ Intermediate⏱ 40 minUndergraduate students and practising engineers.
Interval flavours
Percentile:[qα/2∗,q1−α/2∗]. Simple, and transformation-respecting.
Basic (reverse percentile):[2θ^−q1−α/2∗,2θ^−qα/2∗]. It assumes the distribution of θ^−θ resembles that of θ^∗−θ^.
BCa (bias-corrected and accelerated): adjusts the percentiles for bias and skewness. It’s more accurate (second-order correct) and the standard choice when it matters (Efron, 1987).
Studentized bootstrap-t: bootstrap (θ^∗−θ^)/SE∗. It’s also second-order accurate, but needs an SE for each replicate.
Respect the data’s structure
Stratified: with runs × tasks, resample runs within each task. Don’t mix tasks.
Time series: the i.i.d. bootstrap destroys autocorrelation and badly understates the SE. The moving block bootstrap resamples contiguous blocks of length ℓ∼n1/3 (Künsch, 1989).
Regression: resample (x, y) pairs, or residuals from a fitted model.
When the bootstrap fails
Extremes: for the sample maximum, about 63% of replicates equal the observed max, and the bootstrap distribution can’t extend beyond it.
Tiny samples: with n=5, F^n is a poor stand-in for F, and intervals under-cover.
Heavy tails without a variance, statistics at the edge of the parameter space, and non-smooth functionals.
🐍 Exercise 1: bootstrap SEs and intervals
Implement a vectorized bootstrap, its SE, and the percentile and basic intervals. Check that the SE of the mean matches s/√n, and that percentile intervals for the median of skewed (lognormal) task times cover about 95%.
📝 Quick check (Level 2)
0/3 answered
1. For a correlated time series, use…
2. The bootstrap is unreliable for…
3. Measurements from several robots should be resampled…
Level 3: Advanced
★★★★☆ Advanced⏱ 40 minGraduate level, with full derivations and proofs.
Why it works (and when)
The bootstrap approximates the unknown distribution of n(θ^−θ) under F by the computable distribution of n(θ^∗−θ^) under F^n. By Glivenko–Cantelli (A4.3-4), F^n→F uniformly. If the functional T is smooth (Hadamard differentiable), the delta method in function space carries this convergence through to the statistic. So the bootstrap is consistent for means, medians, quantiles, trimmed means and smooth functions of moments (Bickel and Freedman, 1981; van der Vaart, 1998). The maximum is not smooth at the boundary, and the argument breaks.
P(observed max is repeated)
The maximum x(n) appears in a resample unless all n draws miss it: P=1−(1−1/n)n→1−1/e. So the bootstrap distribution of n(x(n)−x(n)∗) has an atom of mass 0.63 at 0, while the true limiting distribution (for example exponential, A4.3-8) has none.
Jackknife, cross-validation and bagging
Jackknife: leave one out at a time. Bias ≈(n−1)(θˉ(⋅)−θ^) and SE2≈nn−1∑(θ^(i)−θˉ(⋅))2. It’s a linear approximation to the bootstrap, and it fails for the median.
Cross-validation: resampling used to estimate prediction error, not the variance of a statistic.
Bagging and random forests: average models trained on bootstrap resamples to reduce variance. The out-of-bag points give a free error estimate (Breiman, 1996, 2001).
Exercise 3.1: Show that the bootstrap SE of the mean is s·√((n − 1)/n)/√n
Under F^n, a single draw has variance σ^2=n1∑(xi−xˉ)2. The mean of n i.i.d. draws has variance σ^2/n. As B→∞, the bootstrap SE converges to σ^/n=s(n−1)/n/n.
📝 Quick check (Level 3)
0/3 answered
1. Bootstrap consistency for smooth statistics follows from…
2. The jackknife fails for…
3. Bagging averages models trained on…
Level 4: Expert
★★★★★ Expert⏱ 40 minResearchers: original papers and open problems.
Honest uncertainty for benchmark scores
Deep-RL results are often a few seeds per task across many tasks, with occasional collapsed runs. Agarwal et al. (2021) recommend the interquartile mean (IQM) across all runs and tasks as a robust aggregate, reported with a stratified bootstrap confidence interval: resample seeds within each task. With 10 tasks × 5 seeds, the honest interval is wide, and it covers a little below 95% because each task has only 5 runs. That’s a reason to run more seeds, not to drop the interval. The same recipe applies to robot success rates across environments and to model accuracy across data shards.
🐍 Exercise 2 (research): stratified bootstrap CIs for an interquartile mean
Simulate 10 tasks × 5 seeds with occasional collapses. Compute the IQM and its stratified-bootstrap 95% CI, check coverage against the population IQM, and show that the bootstrap fails for the sample maximum (P(max* = max) ≈ 1 − (1 − 1/n)ⁿ).
Resampling in AI, robotics and aerospace
Model evaluation. Bootstrap CIs on test accuracy, AUC or calibration error. Paired bootstrap for comparing two models on the same test set (Koehn, 2004, for MT; widely used across ML).
Ensembles and uncertainty. Bagged ensembles and bootstrapped DQN use resampling to represent epistemic uncertainty and drive exploration (Osband et al., 2016).
Particle filters resample particles by weight (A4.3-4), a different “bootstrap”: Gordon, Salmond and Smith (1993) called it the bootstrap filter.
Reliability and dispersion analysis. Bootstrap CIs for percentiles of Monte Carlo outputs, and block bootstraps for correlated simulation output.
Robotics benchmarks. Cluster bootstraps by robot or by environment avoid treating repeated runs as independent.
References
B. Efron (1979). “Bootstrap methods: another look at the jackknife.” Annals of Statistics, 7(1).
B. Efron (1987). “Better bootstrap confidence intervals.” JASA, 82(397).
B. Efron, R. Tibshirani (1993). An Introduction to the Bootstrap. Chapman & Hall.
A. Davison, D. Hinkley (1997). Bootstrap Methods and Their Application. Cambridge University Press.
P. Bickel, D. Freedman (1981). “Some asymptotic theory for the bootstrap.” Annals of Statistics, 9(6).
H. Künsch (1989). “The jackknife and the bootstrap for general stationary observations.” Annals of Statistics, 17(3).
L. Breiman (1996). “Bagging predictors.” Machine Learning, 24.
R. Agarwal, M. Schwarzer, P. Castro, A. Courville, M. Bellemare (2021). “Deep reinforcement learning at the edge of the statistical precipice.” NeurIPS.
I. Osband, C. Blundell, A. Pritzel, B. Van Roy (2016). “Deep exploration via bootstrapped DQN.” NeurIPS.
N. Gordon, D. Salmond, A. Smith (1993). “Novel approach to nonlinear/non-Gaussian Bayesian state estimation.” IEE Proceedings F, 140(2).
The jackknife approximates the bootstrap for smooth statistics, but not for the median.
Practice
Show:
Level 0
Problem 1Level 0
Can a bootstrap sample contain the same data point twice? (yes/no)
Yes: it’s drawn with replacement.
Problem 2Level 0
You have 40 observations. How many points does each bootstrap resample have?
40.
Problem 3Level 0
The bootstrap SE is the ____ of the resampled statistics.
The spread (standard deviation).
Level 1
Problem 4Level 1
Limit of the expected fraction of distinct points in a resample, 1−1/e?
≈0.632.
Problem 5Level 1
For n=2, what is the expected fraction of distinct points, 1−(1/2)2?
0.75.
Problem 6Level 1
s=3, n=100. Approximately what is the bootstrap SE of the mean?
≈s/n=0.3.
Problem 7Level 1
With B=1000 sorted replicates, which (1-based) replicate is near the 2.5% quantile?
About the 25th.
Level 2
Problem 8Level 2
Basic interval: θ^=10, q0.025∗=9.0, q0.975∗=10.8. What is the lower limit?
2⋅10−10.8=9.2.
Problem 9Level 2
And the basic upper limit?
20−9.0=11.
Problem 10Level 2
P(max∗=max) for n=50, 1−0.9850?
0.9850=0.364, so ≈0.636.
Problem 11Level 2
Block bootstrap: a series of 1000 points. What block length is roughly n1/3?
10.
Problem 12Level 2
What fraction of points is out-of-bag on average (large n)?
1/e≈0.368.
Problem 13Level 2
Runs are nested within 8 robots. What unit should you resample?
The robot (cluster).
Level 3
Problem 14Level 3
Derive the probability that the sample maximum appears in a bootstrap resample.
Each draw misses it with probability 1−1/n, independently. So it appears with probability 1−(1−1/n)n→1−1/e. ∎
Problem 15Level 3
Show that the ideal bootstrap SE of the mean is σ^/n.
Under F^n, a draw has variance σ^2. The average of n i.i.d. draws has variance σ^2/n. ∎
Problem 16Level 3
Explain why the i.i.d. bootstrap understates the SE for autocorrelated data.
Resampling individual points breaks the correlation. The resampled series behaves like i.i.d. data with variance σ2/n, missing the factor 1+2∑ρk (A5.1-2). Block resampling keeps short-range dependence. ∎
Problem 17Level 3
For a tiny sample, n=5, what is the expected fraction of distinct points in a resample, 1−(4/5)5?
1−0.32768=0.67232.
Level 4
Problem 18Level 4
What fraction of scores does the interquartile mean use?
The middle 50%.
Problem 19Level 4
In a stratified bootstrap of runs × tasks, you resample runs within each ____.
Task.
Problem 20Level 4
The bootstrap CI is wide and under-covers with 5 seeds per task. What’s the remedy?
Run more seeds (more runs per task).
Coding practice
🐍 Code 1 (Level 1): how much of the data is in a resample?
Simulate the average fraction of distinct points in bootstrap resamples.
🐍 Code 2 (Level 2): bootstrap SE of the mean
Compute the bootstrap SE of the mean and compare it with s/√n.
🐍 Code 3 (Level 2): percentile interval
The 2.5% and 97.5% quantiles of a set of replicates.
🐍 Code 4 (Level 3): the bootstrap's blind spot
The probability that a bootstrap maximum equals the sample maximum.
🐍 Code 5 (Level 4): moving block bootstrap
Estimate the SE of the mean of an AR(0.8) series by resampling blocks, and compare with the naive SE.
Topic test
A timed test drawn at random from this topic's question bank. Each attempt gets new questions. For a longer test across the whole chapter, see the chapter test, or mix topics in the question bag.
Bootstrap and Resampling: topic test
10 questions, drawn at random from a bank of 16. Every attempt is different.
⏱ Time limit: 15 minutes. The test submits itself when time runs out.
Levels covered: 0, 1, 2, 3, 4. No hints or solutions until you submit.