You have eight response times and no way to get more. Draw from them again, with replacement, a thousand times, and watch their mean wobble.
One sample, a thousand what-ifs
Eight response times, resampled 1000 times with replacement (seed 6500).
One sample of eight response times, in ms. Resample it: draw 8 of its values at random, with replacement, and take their mean.
Predict first. Draw 8 values from these eight, with replacement. How many different values will one resample hold?
Describe this picture
Three panels that stay apart, stacked on one scale in ms. The first, “the one sample we have”, shows the eight response times 12, 14, 15, 15, 16, 18, 19 and 21 ms as dots, the two 15s stacked. The second, “one resample”, shows 8 values drawn from those eight with replacement: repeated values stack up, a triangle marks their mean, and the sample values not drawn are greyed out in the first panel. The third, “means of many resamples”, is a histogram of the resample means. Before the clip a question asks how many different values one resample of 8 will hold: all 8, about 5, or about 3. A tap picks one and starts the clip. In the clip 1000 resamples are drawn (seed 6500): the first ten one by one, each dropping its mean into the histogram, then the other 990 pour in. On a wide screen a small tally beside the second panel counts the different values in each of the first ten resamples: 3 to 6, mostly 4 or 5; at the end your guess is a dotted line on it. At the end a bracket over the histogram marks the middle 95 % of the means, 14.500 to 18.125 ms. Readouts give the number of resamples and the spread of their means, 0.9326 after 1000. After the clip a slider, “Resamples counted”, sets how many resamples are counted, from 10 to 1000 in steps of 10; the spread readout wanders with few and settles as the count grows.
Resampling a single sample
To see how much a statistic wobbles, I would like many samples from the population. I have one. The bootstrap pretends the sample is the population, and draws new samples from it: values, chosen at random with replacement, so a value can be picked twice or not at all. Each such draw is a resample.
Before the clip you guessed how many different values a resample holds. About 5 of the 8, on average. Each value is missed by all 8 draws with chance , so about a third of the values are absent from any one resample, and are present. For large samples the missing share approaches .
The resamples are not new data. They hold nothing but the same eight values, rearranged. What they show is how much a statistic would change if the sample had come out a little differently.
The spread of the resample means
Compute the mean of each resample: for resamples, the star marking “computed from a resample”. Their histogram is centred on , the mean of the sample, not on the unknown true mean. The bootstrap cannot see past the sample.
The spread of the resample means is the bootstrap standard error:
After the clip, drag the number of resamples. The readout wanders with few resamples and settles near ms as they grow; the clip’s 1000 resamples give . That limit is the spread of the sample itself, computed with divisor , , divided by . The formula of Confidence intervals, with divisor , gives : slightly larger, for the reason Estimators: bias and variance gave.
More resamples make the readout steadier, but they never make the sample bigger. A thousand resamples still carry only the information in eight values.
A percentile interval
The resample means also give an interval with no formula at all. Sort them and cut off the lowest 2.5 % and the highest 2.5 %: what is left is a 95 % percentile interval. For the eight times the clip’s 1000 resamples give 14.5 to 18.125 ms, roughly ; with many more resamples it settles near 14.4 to 18.1.
The t interval of Confidence intervals for the same data was 13.81 to 18.69 ms, a little wider: with eight values, the bootstrap underestimates the spread, as the divisor above suggests.
Statistics with no formula
For a mean, the formula already does the job. The bootstrap earns its keep where no simple formula exists: the median, a ratio, a correlation, a trimmed mean. The recipe is the same: compute the statistic on each resample, then read the spread and the percentiles off the histogram. For the median of the eight times, the bootstrap standard error is about 1.3 ms.
When it fails
Watch out
The bootstrap treats the sample as the population, so it fails where the sample is a poor stand-in. With very small samples there are only a few different resamples. For extremes, such as the largest value, the sample’s own maximum is never exceeded by any resample.
Take the maximum of eight values. A resample contains the sample’s maximum with chance , so about two resamples in three report exactly that value. The bootstrap histogram of the maximum is mostly one tall spike, while the true distribution of a sample maximum over new samples has no spike at all. For large samples the spike holds about of the resamples.
Worked example
1. Every resample of a tiny sample. The sample has equally likely ordered resamples. Their means take these values:
| Resample mean | Resamples | Chance |
|---|---|---|
| 1, 2, 6 | 1 each | 1/27 each |
| 4/3, 5/3, 8/3, 10/3, 13/3, 14/3 | 3 each | 3/27 each |
| 3 | 6 | 6/27 |
The mean of these 27 means is 3, the sample mean. Their variance is , standard deviation . That equals the sample’s spread with divisor , , divided by : the bootstrap standard error of a mean is always the plug-in spread over .
2. The eight times. About 34 % of the values are missing from each resample and 5.25 are present. There are ordered resamples, but only different collections of values. The bootstrap standard error of the mean tends to , a little below the formula’s .
3. The maximum. At a resample repeats the sample maximum with chance ; the bootstrap is not to be trusted for it.
Try it yourself. Draw 8 from 8 with replacement: a given value is missing with chance . The bootstrap histogram of the mean centres on the sample mean.
Where you’ll meet this
Standard errors without formulas. Medians, ratios of two means, correlations and the coefficients of complicated models often get their error bars from the bootstrap in everyday statistics software.
Experiments on skewed data. Revenue per visitor is lopsided: most visitors spend nothing, a few spend a lot. Online A/B tests often bootstrap the difference in mean revenue instead of trusting a bell.
Curves and peaks. The uncertainty of a fitted curve, or of the position of a peak in a spectrum, is found by refitting to resampled data and watching the result move.
Where this leads · a selection matrix
A resample is a matrix times the data vector: a matrix with one 1 in each row, in the column of the value drawn. A matrix moves the plane in the linear algebra course reads such a matrix.
Reference card
| Quantity | Formula | Notes |
|---|---|---|
| Resample | draws from the sample, with replacement | not new data |
| Missing from a resample | , tends to | about a third |
| Bootstrap standard error | SD of | mean: plug-in SD |
| Percentile interval | 2.5th to 97.5th percentile of the | no formula needed |
| Centre | the sample’s statistic | not the truth |
| Fails for | tiny samples, maxima and minima | resamples repeat the extreme |