Bootstrapping
Overview
The bootstrap principle treats the empirical distribution as an approximation of the true population distribution . By resampling from (with replacement), we approximate the sampling distribution of any statistic. The algorithm: (1) resample data with replacement times (typically 10,000), (2) compute the statistic on each resample, (3) take percentiles of the bootstrap distribution as the confidence interval. The percentile method is simple and intuitive. The BCa (bias-corrected and accelerated) method improves accuracy by adjusting for bias and skewness. Permutation tests complement bootstrapping by building exact null distributions for hypothesis testing.
Key Concepts
Bootstrap CI Methods
| Method | Description | Best When | Accuracy |
|---|---|---|---|
| Percentile | Direct quantiles of bootstrap distribution | Statistic is symmetric | Good |
| BCa | Bias-corrected and accelerated | Statistic is biased or skewed | Better |
| Basic (Pivotal) | Symmetric distributions | Good | |
| Studentized | Uses bootstrap estimate of SE | Most accurate | Best (expensive) |
Quick Example
When to Use Bootstrap vs. Parametric Methods
| Scenario | Recommended Approach |
|---|---|
| Normal data, known Ο | Z-interval (parametric) |
| Normal data, unknown Ο | t-interval (parametric) |
| Skewed data, | Bootstrap CI |
| Any statistic (median, ratio) | Bootstrap CI |
| Small sample () | BCa bootstrap or double bootstrap |
| Hypothesis test, any distribution | Permutation test |
| Model comparison | Paired bootstrap or permutation |
Python Implementation Tips
import numpy as np
def bootstrap_ci(data, stat_fn=np.mean, n_boot=10000, ci=0.95):
"""Bootstrap confidence interval for any statistic."""
n = len(data)
boot_stats = np.array([
stat_fn(np.random.choice(data, n, replace=True))
for _ in range(n_boot)
])
lower = np.percentile(boot_stats, (1 - ci) / 2 * 100)
upper = np.percentile(boot_stats, (1 + ci) / 2 * 100)
return lower, upper, boot_stats
Key points: (1) Always set a random seed for reproducibility. (2) Use np.random.choice(data, n, replace=True) for with-replacement resampling. (3) At least resamples for stable bounds.
Key Takeaways
Deep Dive
For detailed explanations, worked examples, and Python implementations, explore the dedicated statistics lessons:
Bootstrap Methods
- Bootstrap Methods β Complete theory, algorithms, when each method is appropriate, and Python implementation
Bootstrap Confidence Intervals
- Bootstrap Confidence Intervals β Percentile, BCa, pivotal, and studentized methods with detailed examples
Related Topics
- Permutation Tests β Exact hypothesis tests by shuffling labels
- Confidence Intervals for the Mean β Parametric alternatives when assumptions hold
- Point Estimation β MLE and the sampling distributions bootstrapping approximates
- Nonparametric Methods β Other distribution-free statistical methods