Bootstrap assumptions
Quick answer
The bootstrap approximates how a statistic would vary by resampling from the observed data. In the ordinary nonparametric bootstrap for independent identically distributed units, each resample has the original sample size and is drawn with replacement. Recompute the statistic on each resample; their distribution approximates sampling variability under suitable conditions.
Enumerate a tiny bootstrap
With observed weights [2, 6], the empirical distribution assigns mass 1/2 to each observation. Drawing two items with replacement gives four equally likely ordered index sequences. Means are 2, 4, 4, 6. The exact conditional bootstrap variance of this statistic is 2; its standard error is sqrt(2). This distribution is conditional on the observed sample, not the unknown true population. In realistic samples, enumeration grows rapidly, so we simulate a finite number B of resamples. The standard deviation across simulated statistics estimates bootstrap SE; using B−1 estimates the variance of the resampled statistic distribution.
from itertools import productfrom statistics import mean, pvarianceobserved = [2, 6]means = [mean(s) for s in product(observed, repeat=2)]print(means)print(round(pvariance(means)**0.5, 4))Expected output (local Python 3.13.5):
[2, 4, 4, 6]1.4142The exact finite bootstrap distribution gives SE about 1.4142, conditional on these two observations.
Choose the resampling unit
A fictional classifier is tested on two images from each of three devices. Images from the same device may share lighting and manufacturing conditions. To estimate uncertainty for a population of independent devices, a cluster bootstrap can resample whole devices, preserving all images and their paired predictions together. The statistic must also match the target: an equal-device average is not always the same as an equal-image average. When time order matters, a suitable block bootstrap may preserve local dependence. The ordinary IID bootstrap does not automatically work for rare events, very small samples, extreme quantiles or dependent data. Percentile intervals use quantiles of bootstrap estimates, but their coverage is not universally 95%.
from statistics import meandevices = [[1, 1], [0, 1], [0, 0]]# One illustrative resample of whole device indices, with replacement.indices = [0, 0, 2]print(mean([mean(devices[i]) for i in indices]))print(mean([mean(d) for d in devices]))Expected output (local Python 3.13.5):
0.66666666666666660.5The resample repeats device 0 and omits device 1. The original device-weighted accuracy is 0.5; this resample is 2/3.
Common mistakes
Sampling without replacement at the full original size merely reorders the sample and cannot change its mean. Resampling dependent rows as if independent often understates uncertainty. A seed makes a simulation repeatable in a fixed environment, not necessarily accurate; increasing B reduces Monte Carlo error but does not fix poor sampling design. To compare two models on the same records, resample paired outcomes together.
Practice and next steps
Enumerate the four ordered bootstrap resamples from [1, 5]. Calculate their mean values and explain why repeating one observed item is allowed. Next, use rearranged labels to test a null model rather than estimate uncertainty.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Bootstrap assumptions — knowledge check
Apply statistical reasoning to original synthetic examples.
How does an ordinary IID bootstrap draw observations?
What is the usual resample size for an ordinary bootstrap?
What happens if you merely reorder all original values?
Rows share a device identity. Which resampling unit may preserve dependence?
What does increasing the number of bootstrap replicates primarily reduce?