Bootstrap resampling
Bootstrap 重采样
Separate sampling uncertainty from Monte Carlo error, enumerate a complete bootstrap distribution, and explain why resampling fails for a uniform endpoint.
bootstrapReuse data to study an estimator’s wobble
Suppose three observed task durations are 1, 2 and 6 minutes. Their mean is three minutes. How much might the mean change if another sample were collected? We do not know the population distribution. The empirical bootstrap temporarily uses the observed distribution as a stand-in: draw three values with replacement from those three observations, compute the mean, and repeat.
One resample might be [1,1,6], another [6,6,6]. Duplicates are intentional. Sampling all three without replacement would only reorder the original values and leave the mean unchanged. Efron’s 1979 paper describes estimating a statistic’s sampling distribution this way, while also connecting the method with earlier jackknife work. Efron, 1979, Sections 1–2
These simulated datasets are not new observations from the population. The bootstrap asks what an estimator would do under a fitted approximation to that population. Whether the answer is useful depends on the estimator, the data, and the sampling assumptions.
Keep the real and resampled worlds separate
Assume the original observations are i.i.d. from F, and let estimate a population quantity θ. The empirical distribution assigns weight 1/n to each observed row, so repeated values receive their combined weight:
Conditionally on the observed data, draw independently from and compute . The intended approximation is between the sampling distribution of under F and the conditional distribution of under . For asymptotic comparisons one must also choose the appropriate scaling, often for regular estimators.
There are two errors: replacing F by , and using finitely many Monte Carlo replicates to approximate the distribution under . Increasing the number of replicates B addresses the second error. It does not remove the first. Oxford Computational Statistics, Sections 3.1 and 4
For a sample mean, the conditional moments can be derived directly. Write a star on expectations and variances taken over resampling with the original data fixed:
Conditional independence therefore gives
where is the usual sample variance with denominator n−1, when n≥2. Compare this with the conventional estimate of the true mean’s sampling variance: the finite-sample bootstrap version has factor (n−1)/n. It is not exactly equal to the unknown population quantity just because we can calculate it exactly.
For [1,2,6], the squared deviations sum to fourteen. The conditional variance of the resampled mean is 14/9, while . These are different answers to different finite-sample calculations.
For interval construction, let be the a quantile of the conditional distribution of . The percentile interval uses . The basic interval reflects those quantiles around the original estimate:
The reflection follows by estimating quantiles of the error with those of , then solving for θ. Neither construction automatically has exact nominal coverage. Efron’s original discussion already cautioned that turning a bootstrap distribution into a confidence statement requires care. MIT 18.05, Class 24 · Efron, Section 8, Remark D
Enumerate the tiny case before simulating
Three indexed observations produce equally likely ordered resamples. The program enumerates them, preserving duplicate multiplicities, so we can compare a Monte Carlo variance estimate with the exact conditional answer. The quantile convention is the inverse empirical CDF with the minimum used at probability zero; no interpolation is performed.
import itertools
import math
import random
from fractions import Fraction as F
def mean(values):
return sum(values,F(0))/len(values)
def exact_resamples(data, statistic):
data = tuple(data)
if not 1<=len(data)<=6 or any(not isinstance(x,F) for x in data):
raise ValueError("one to six Fraction observations required")
return sorted(statistic(sample) for sample in itertools.product(data,repeat=len(data)))
def sampled_means(data, B=2000, seed=7):
data = tuple(data)
if not data or any(not isinstance(x,F) for x in data):
raise ValueError("nonempty Fraction data required")
if type(B) is not int or B<2 or B*len(data)>2_000_000:
raise ValueError("at least two replicates, at most two million draws required")
rng = random.Random(seed)
return [mean(rng.choices(data,k=len(data))) for _ in range(B)]
def quantile(sorted_values, probability):
if not sorted_values or not isinstance(probability,F) or not 0<=probability<=1:
raise ValueError("nonempty sorted values and Fraction probability in [0,1] required")
# Inverse empirical CDF; q(0) is defined here as the minimum.
index = max(0,math.ceil(probability*len(sorted_values))-1)
return sorted_values[index]
x = tuple(map(F,[1,2,6]))
theta = mean(x)
values = exact_resamples(x,mean)
exact_center = mean(values)
variance = mean([(v-exact_center)**2 for v in values])
assert len(values)==27 and theta==mean(values)==3
assert variance==F(14,9)
qlo,qhi = quantile(values,F(1,40)),quantile(values,F(39,40))
percentile = (qlo,qhi)
basic = (2*theta-qhi,2*theta-qlo)
assert percentile==(1,6) and basic==(0,5)
replicates = sampled_means(x)
mc_center = mean(replicates)
mc_variance = sum((v-mc_center)**2 for v in replicates)/(len(replicates)-1)
print("exact conditional variance:",float(variance))
print("Monte Carlo variance estimate:",float(mc_variance))
maxima = exact_resamples(x,max)
assert F(maxima.count(max(x)),len(maxima))==F(19,27)
assert max(maxima)==max(x)
The nominal 95% percentile and basic constructions here give [1,6] and [0,5], respectively. These are deliberately tiny-data illustrations, not verified 95% coverage guarantees. Their disagreement is visible evidence that “bootstrap interval” does not specify a unique method. Increasing B would only estimate the same conditional quantiles more precisely.
Enumeration requires statistic evaluations. For the mean this takes arithmetic operations, followed by sorting values, and stores scalar objects. Exact fractions have additional bit costs. The six-observation limit prevents accidental exponential workloads. Monte Carlo sample means use O(Bn) arithmetic and O(B+n) storage here. Computing the displayed variance costs another O(B) operations; its B−1 denominator removes the finite-B bias for estimating the conditional variance, not the bias from replacing the original population.
Use a fixed seed for reproducibility, and record B and the quantile rule. The bootstrap distribution itself does not depend on the seed; its finite Monte Carlo approximation does. Run independent seeds when checking simulation stability, and increase the number of original observations when the issue is missing population information.
A sample maximum exposes a failure
Suppose the actual observations are i.i.d. from a continuous uniform distribution on [0,θ], with θ>0. The sample maximum M is strictly below θ with probability one for finite n. Every ordinary resample maximum is at most M. Consequently, the upper endpoint of a percentile interval built from those maxima is also at most M and misses θ with probability one. More bootstrap replicates cannot repair this interval.
There is a sharper distributional problem. The observed maximum is unique almost surely, and a resample contains it with probability
Thus the resampled, scaled error retains a point mass at zero. The target error tends instead to a continuous negative-exponential law: for nonnegative t and sufficiently large n, . The ordinary bootstrap cannot reproduce that limit. This calculation is a counterexample, not a claim that every statistic based on extremes is hopeless. A parametric bootstrap or a different resampling scheme requires separate justification.
For means with i.i.d. observations and finite positive variance, the ordinary bootstrap does have a suitable large-sample consistency result. That result does not turn all statistics into regular estimators. Oxford notes, Section 4, Theorem 14
The resampling unit must preserve the structure that matters. Resample paired features and labels together; sampling columns independently destroys their relationship. Correlated observations within a subject, cluster, or time series need a design that accounts for that dependence. A parametric bootstrap samples from a fitted model rather than the empirical distribution and therefore adds model assumptions. None of these choices repairs biased recruitment or omitted populations by itself.
Ask which uncertainty was estimated
- Why is sampling without replacement unsuitable for the ordinary bootstrap mean when the resample size equals n? Answer: Every resample contains the same observations once, so the mean never changes.
- The data are [1,1,6]. What probability should one resampled draw assign to 1? Answer: 2/3. Deduplicating the values and drawing uniformly would incorrectly use 1/2.
- B rises from 1,000 to 100,000 while the original sample stays fixed. Have you acquired more independent evidence about the population? Answer: No. You have reduced Monte Carlo error for the same fitted resampling distribution.
- For three distinct observations, what is the chance that the resample includes the observed maximum? Answer: . A large atom remains at the maximum; this explains part of the uniform-endpoint failure.
Match the method to the target
Bootstrap uncertainty estimation, cross-validation, permutation tests, and data augmentation reuse data for different purposes. A permutation test needs a null hypothesis and an appropriate invariance assumption. Cross-validation estimates predictive performance under a specified splitting scheme. Resampling alone does not make these questions interchangeable.
When reading an empirical AI paper, locate the resampling unit, statistic, interval method, number of replicates, and treatment of model fitting. A bootstrap over held-out cases for one fixed model estimates different uncertainty from a procedure that resamples training data and retrains the model. Report which experiment was actually performed.
Make a prediction, then check
With the original data fixed, what does increasing bootstrap replicates one hundredfold primarily reduce?
Learning objectives
- Derive the conditional bootstrap variance of a mean and distinguish original sample size from replicate count.
- Enumerate a resampling distribution and explain the maximum counterexample and the role of resampling units.
Prerequisites & connections
Explore related knowledge →References
- Bootstrap Methods: Another Look at the Jackknife
Bradley Efron · 1979 - Computational Statistics — Lecture notes: The Bootstrap, version 5 February 2019
François Caron · 2019 - Introduction to Probability and Statistics — Statistics Reading, Classes 22–24
Jeremy Orloff; Jonathan Bloom; MIT OpenCourseWare · 2022
Version1 · Editorial status: Recorded technical checks completed
View technical check record (AI)
Codex · 2026-09-05 · Codex multi-agent technical check: primary-source verification, derivation and numerical assertions, bilingual comparison, and review by another agent or the parent; no independent human peer review.
- Used independent weighted convolutions to verify complete resampled-mean distributions with duplicates, conditional means and variances; separately checked empirical quantile conventions, boundary inputs and simulations with two fixed seeds.
- Enumerated unique-maximum resamples for n=1 through 6, verifying zero-point mass 1−(1−1/n)^n, and independently derived the continuous limit of the uniform endpoint error.
- Cross-review found repeated mean calculation inside the exact variance loop, causing O(M²) extra cost. Both exact_center and mc_center are now outside their loops, giving O(M) and O(B) variance work. Another agent reconstructed the distribution using multinomial count combinations to verify variance 14/9 and both intervals.
- The parent executed all 30 new checks and all 55 combined probability/inference tests; bilingual code, display equations, six main anchors, citations and four answered exercises were additionally compared.
Source locations checked:
- Bootstrap Methods: Another Look at the Jackknife · Printed pp1–3 (PDF2–4) and Section8 RemarkD printed p21 (PDF22), visually inspected original scan; resampling definition, jackknife relation and confidence-interval caution.
- Computational Statistics — Lecture notes: The Bootstrap, version 5 February 2019 · PDF6–9 conditional resampling and interval construction; PDF12–14 two approximations, Theorem14 and paired resampling. Did not repeat the general bias-ratio claim or guarantee parametric-bootstrap superiority.
- Introduction to Probability and Statistics — Statistics Reading, Classes 22–24 · Class24 PDF151–160 empirical distribution, percentile/basic construction and parametric sampling. Noted source code uses 0.05/0.95 quantiles despite a 95% label; article uses 0.025/0.975 explicitly.
Related topics