Six waiting times of 2, 3, 4, 5, 7 and 9 minutes have median minutes. For a sample mean the estimated standard error is simply , but there is no comparably simple formula for the standard error of a median, and large-sample approximations say little about a sample of six. The bootstrap estimates the sampling variability of such a statistic by recomputing it on many samples drawn from the data themselves. This lesson builds the bootstrap distribution of the median for these six values, reads off a standard error, a bias estimate and a percentile interval, and shows what to resample and what the method cannot deliver.
Key terms
Bootstrap
Definition Let be independent observations from an unknown distribution , and let be a statistic computed from them. The empirical distribution puts probability on each observed record. The sampling distribution of describes its values over repeated samples of size from . The nonparametric bootstrap approximates it by the bootstrap distribution, the distribution of the same statistic computed on samples of size drawn from . Quantities that would require the unknown , such as the standard error or the bias of , are estimated by the same quantities under . For tiny the bootstrap distribution can be found exactly by listing every resample, and otherwise it is approximated by simulation.
In plain words New samples from the population are not available, so the sample stands in for the population and new samples are drawn from it instead. This works when the empirical distribution resembles the population in the features that drive the statistic’s variability. The bootstrap reuses the information already in the data and adds none. It approximates a sampling distribution, and it does not guarantee that an interval built from it has its nominal coverage.
Example For the waiting times, assume the six records are independent observations from one population. Then gives probability to each of 2, 3, 4, 5, 7 and 9 minutes, and the observed median is minutes. There are equally likely ordered resamples, and the medians of all of them form the exact bootstrap distribution of the median. Its values run from 2 to 9 minutes and never leave that range, because the median of resampled values always lies between the smallest and largest observation.
Bootstrap sample
Definition A bootstrap sample, or resample, has the same size as the data and is drawn with replacement from the observed records. Each draw picks every record with probability , independently of the other draws. Every resample is drawn from the original data, never from a previous resample.
In plain words Replacement is what makes a resample differ from the data. A record can appear several times or not at all, and drawing records without replacement would only return the original data in a new order. The chance that a given record is left out of a resample is , which is for and rises toward as grows. Resamples are possible results under the stand-in population, not new observations.
Example One possible resample of the waiting times is . Its third and fourth sorted values are 4 and 7, so its median is minutes. Another is , with median minutes.
Bootstrap standard error
Definition The bootstrap standard error of is the standard deviation of the bootstrap distribution of . In practice one draws resamples, computes with mean and sample variance , and uses
As grows, this estimate converges to the standard deviation of the exact bootstrap distribution, sometimes called the ideal bootstrap standard error.
In plain words Two different errors are involved. The sampling error from having only observations is what the bootstrap standard error estimates. The Monte Carlo error from using finitely many resamples is a numerical error, and it shrinks as grows. A larger makes the answer more stable for the given data, but it adds no information about the population. For the sample mean, the ideal bootstrap standard error equals , where uses the denominator , so for it equals multiplied by .
Example Listing all 46656 resamples gives bootstrap medians with mean and standard deviation minutes, so the ideal bootstrap standard error of the median is about minutes. A simulation with resamples, using NumPy’s default generator with seed 20261012, gives , and seed 20261013 gives . The difference between them is Monte Carlo variation. Recording the seed, and the resampling unit lets anyone repeat the calculation. For comparison, the mean of the same six values has and ideal bootstrap standard error .
Bootstrap bias
Definition The bootstrap estimate of the bias of is
the mean of the bootstrap statistics minus the observed statistic, where is the exact bootstrap mean or its simulated estimate. It estimates the true bias , where is the parameter that estimates, by treating as the population and the observed as its parameter value. That fits when is the plug-in estimate, computed from in the same way that is computed from , as the sample median is for the median. Subtracting the bias estimate from gives the bias-corrected estimate , but the correction adds variability of its own.
In plain words The bootstrap bias shows how the statistic behaves systematically when the sample plays the role of the population. It is itself an estimate with sampling error, and it does not reveal the bias under the real population with certainty. Compare it with the bootstrap standard error before acting on it.
Example For the waiting times the estimate is
minutes. The values above the observed median, 5, 7 and 9, are more widely spaced than those below it, 2, 3 and 4, so a resampled median that moves up tends to move farther than one that moves down. The bias estimate is small next to the bootstrap standard error of about minutes. The bias-corrected median would be minutes.
Percentile interval
Definition The percentile interval with nominal level is
where is a quantile of the bootstrap distribution of . Because a bootstrap distribution is discrete, the quantile rule must be stated. The inverse cumulative distribution rule takes to be the smallest value with , where is the cumulative distribution function of .
In plain words At 95 percent the interval runs from the 2.5th to the 97.5th percentile of the bootstrap statistics. Its coverage is approximate and rests on the bootstrap distribution being a good stand-in for the sampling distribution. It can do badly for biased estimators, parameters near a boundary, extreme statistics such as the sample maximum, and very small samples. Other bootstrap intervals, such as studentized or bias-corrected ones, adjust for some of these problems but have conditions of their own.
Example For the exact bootstrap distribution of the median, the cumulative probabilities include , , and . The inverse cumulative distribution rule therefore gives and , and the nominal 95 percent percentile interval is minutes. Both seeded simulations give the same endpoints. The bootstrap distribution actually places probability on this interval, not , and with only six observations the stated level is a rough guide.
Resampling unit
Definition The resampling unit is the object drawn with replacement in each bootstrap sample. For the bootstrap to imitate the real design, it is the unit that was independently sampled, kept whole with all of its measurements. For paired measurements it is the pair, and for a cluster sample it is the whole cluster, such as a household with all its members. Time series and other dependent sequences need schemes that keep the dependence, such as resampling blocks of consecutive values.
In plain words Resample whatever was independently selected. Splitting a unit apart, by resampling the before and after columns separately or the rows inside clusters one by one, destroys dependence that was really there and changes the sampling behavior of the statistic. The choice follows the design and the target, not the layout of the spreadsheet. A permutation test is a different tool. It rearranges labels in the ways that a stated null hypothesis or the random assignment allows, to judge a test statistic, while the bootstrap resamples units to estimate the variability of an estimate.
Example Three devices are measured before and after a repair, with readings , and . The differences are 2, 1 and 3, with mean difference 2. Resampling devices keeps each pair together, and the ideal bootstrap standard error of the mean difference is . Resampling the before and after columns independently treats the two readings of a device as unrelated, and the same calculation gives
The wrong unit inflates the standard error more than fourteenfold here, because the large differences between devices are counted as noise in the difference.
Check yourself
- Which of the following could be a bootstrap sample of the waiting times ? First , second , third , and fourth .
Show the answer
The first is possible. Sampling with replacement can pick the same record every time, and as an ordered draw this happens with probability . The second is not, because a resample has the same size as the data, six. The third is not, because 8 is not an observed value. The fourth is possible. It contains each record once, which happens for of the ordered resamples.
- For the three observations 1, 3 and 8, find the exact bootstrap distribution of the median, the bootstrap bias estimate and the ideal bootstrap standard error. What is the 95 percent percentile interval with the inverse cumulative distribution rule?
Show the answer
There are equally likely ordered resamples, and the median of three values is the middle one. The median is 1 when at least two draws are 1, which happens in resamples, and by symmetry it is 8 in 7 resamples, leaving 13 with median 3. The bootstrap mean is
so the bias estimate is . The second moment is , so the variance is and the bootstrap standard error is about .
The cumulative probability already reaches at 1, and it first reaches at 8, so the percentile interval is , the whole range of the data. Three observations carry little information, and the bootstrap cannot add any.
- Ten households are selected independently and every member of each household is measured, 34 people in all. The target is the average over households of the household mean. An analyst bootstraps by resampling the 34 people. What should be resampled instead, what does raising from 1000 to 100000 change, and how would a permutation test differ from this bootstrap?
Show the answer
The households were sampled independently, so the household is the resampling unit. Each bootstrap sample draws ten households with replacement, keeps all members of each, and computes the household-level statistic exactly as in the original analysis. Resampling people treats 34 records as independent even though members of one household tend to resemble each other, which usually makes the standard error too small. If the statistic is then computed as a mean over the resampled people, large households also get more weight, which changes the target from an average over households to an average over people.
Raising reduces Monte Carlo error, so the estimate of the bootstrap standard error becomes more stable. It does not add households or make the bootstrap distribution a better model of the population. A permutation test answers a different question. It shuffles group labels as a null hypothesis or random assignment allows, to see how a test statistic would behave if that null were true, while the bootstrap estimates how much an estimate varies from sample to sample.