The idea: plug in the empirical distribution
The sampling distribution of an estimator depends on the unknown distribution of the data. If we knew we could simulate: draw many samples of size from , compute on each, and read off the spread. The bootstrap replaces the unknown by the empirical distribution , which puts mass on each observed point. Drawing from is drawing with replacement from the data.
The nonparametric bootstrap:
- For : draw with replacement from the data and compute .
- Standard error: the standard deviation of .
- Percentile interval: the and quantiles of the .
Its appeal is that can be anything: a median, a Sharpe ratio, a correlation, the maximum drawdown, the coefficient from a whole fitting pipeline. No derivative, no delta method, no Fisher information.
Two separate errors are involved. The Monte Carlo error comes from finite and can be made as small as you like: – is enough for a standard error, for the tails of an interval. The bootstrap error comes from and does not shrink with ; it is what limits the method, and it is what the failure cases are about.
Intervals
- Percentile: . Simple and invariant to monotone transformations, but it can be biased when is biased or its spread depends on .
- Basic (reverse percentile): . It assumes behaves like , and flips the asymmetry.
- Bootstrap-: bootstrap the studentised statistic . More accurate (second-order correct) when a standard error is available for each resample.
- BCa: percentile with bias and skewness corrections; the usual default in statistical software.
A useful fact for interviews: a given observation is absent from a resample with probability , so each resample contains about 63.2% of the distinct original points. That is also where the out-of-bag fraction in random forests comes from.
Worked example
the exact bootstrap of a mean
The data are . Find the exact bootstrap distribution of the sample mean, its bootstrap standard error, and compare with the usual .
Show solutionHide solution
There are equally likely ordered resamples (10 distinct multisets). The resample mean is with i.i.d. uniform on , so
So and the bootstrap SE is . Enumerating all 27 resamples confirms this.
The usual estimate uses : . The bootstrap uses the plug-in variance (divisor ), so its SE is smaller by . Negligible for , an 18% understatement for : the bootstrap is a large-sample method.
The distribution is also right-skewed: it is centred at 3 but runs from 1 to 6, and its upper tail (means of , and ) comes entirely from resamples that contain the 6. A percentile interval inherits that skew, which is appropriate if the population is skewed and misleading if the skew is an accident of three points.
When the bootstrap fails
The bootstrap works when is a smooth function of averages and the data are i.i.d. with enough moments. It fails, or needs modification, in four standard situations.
1. Extremes and other non-smooth statistics. For Uniform() the MLE is the sample maximum. A resample contains the sample maximum with probability , so the bootstrap distribution of has a 63% point mass at , while the true sampling distribution of is continuous (approximately exponential). The bootstrap cannot see values beyond the largest observation. The same goes for extreme quantiles, VaR at very high confidence, and the maximum drawdown of a short series.
2. Heavy tails. For the mean of data with infinite variance (tail index below 2) the bootstrap is inconsistent. With finite but large kurtosis it is consistent but slow: the bootstrap SE inherits the noise of the sample variance, which is dominated by the few largest observations, so intervals undercover in samples of realistic size. Financial returns sit in this regime; the bootstrap SE of a Sharpe ratio from two years of daily data can be badly off.
3. Parameters at a boundary. If the true value is on the edge of the parameter space (a variance component of zero, a constrained weight at its limit) the bootstrap distribution is wrong. The -out-of- bootstrap (resample points) repairs this and the extremes case at the price of choosing .
4. Dependence. Resampling individual observations destroys the serial dependence. For a positively autocorrelated series the variance of the mean is larger than ; for an AR(1) with coefficient the long-run variance is , three times when . An i.i.d. bootstrap reports and is over-confident.
The block bootstrap
For time series, resample blocks of consecutive observations and glue them together. Within a block the dependence is preserved; between blocks it is broken, so blocks must be long relative to the correlation length. The moving-block bootstrap draws blocks of fixed length starting at random positions; the stationary bootstrap (Politis–Romano) draws geometric block lengths with mean so the resampled series is itself stationary; the circular version wraps around the end. A standard rule of thumb is for variance estimation, tuned to the persistence of the data.
Worked example
i.i.d. versus block bootstrap on an AR(1)
Simulate 500 points of an AR(1) with . Estimate the standard error of the sample mean with an i.i.d. bootstrap and with moving-block bootstraps, and compare with the true asymptotic value.
Show solutionHide solution
The stationary variance is and the long-run variance is , so the true SE of the mean is . An i.i.d. bootstrap can only see and should give about .
import random
import statistics as st
random.seed(7)
phi, n = 0.5, 500
x, prev = [], 0.0
for _ in range(n + 100): # AR(1) with 100 burn-in steps
prev = phi * prev + random.gauss(0, 1)
x.append(prev)
x = x[100:]
def boot_se(data, block, reps=2000):
m = len(data)
starts = range(m - block + 1)
means = []
for _ in range(reps):
sample = []
while len(sample) < m: # glue random blocks of consecutive points
s = random.choice(starts)
sample.extend(data[s : s + block])
means.append(sum(sample[:m]) / m)
return st.stdev(means)
print(f"iid bootstrap SE {boot_se(x, 1):.4f}")
print(f"block (length 10) {boot_se(x, 10):.4f}")
print(f"block (length 25) {boot_se(x, 25):.4f}")
print(f"true asymptotic SE {(1 / (1 - phi)) / n ** 0.5:.4f}")
# iid bootstrap SE 0.0538
# block (length 10) 0.0932
# block (length 25) 0.1104
# true asymptotic SE 0.0894
The i.i.d. bootstrap (block length 1) understates the SE by about 40%, as predicted: it would make a mean look times more significant than it is. Blocks of length 10 recover the right order of magnitude. The length-25 answer overshoots, which shows the trade-off: longer blocks reduce bias from cutting dependence but leave fewer effectively independent blocks (20 here), so the estimate gets noisier. For a single series of 500 points, either estimate is itself uncertain by 10–20%.
Knowledge check
You bootstrap a dataset of 100 observations. What is the probability that a particular observation does not appear in a given resample?
Knowledge check
You use the bootstrap to put an interval on the upper endpoint of a Uniform(0, θ) distribution, estimated by the sample maximum of 200 points. Why is the result unreliable?
Knowledge check
Daily P&L of a strategy has first-order autocorrelation of +0.3. An i.i.d. bootstrap of the mean daily P&L will most likely:
Key takeaways
- The bootstrap replaces by the empirical distribution: resample with replacement, recompute, and use the spread of the replicates. It works for any statistic you can compute.
- Monte Carlo error falls with ; the error from does not. Small samples give plug-in (divisor ) answers that are too narrow.
- It fails for extremes and non-smooth statistics, infinite-variance or very heavy-tailed data, and parameters on a boundary; -out-of- or parametric bootstraps help.
- For dependent data use block, stationary or circular bootstraps with blocks longer than the correlation length; an i.i.d. bootstrap of autocorrelated P&L overstates significance.
- Resample the independent unit and the whole pipeline.
Practice problems
Finished reading?
Answer the 3 knowledge checks to complete this lesson (0 done).