Guide
Bootstrap resampling explained
Harbor Analytics shipped a checkout redesign and reported a +2.1 percentage-point
lift in conversion. Leadership asked the obvious follow-up: how confident are we that
the lift is real, not noise? The sample was only 8,400 sessions — too small for
the normal approximation to feel trustworthy on a skewed, bounded metric. The team ran a
bootstrap: resample observed sessions with replacement ten thousand times,
recompute the lift on each replicate, and read off a 95% confidence interval from the
resulting distribution. The interval was [+0.4pp, +3.8pp] — entirely above
zero, so they shipped. Bootstrap resampling is a simulation-based way to
quantify uncertainty when you cannot assume Gaussian errors or know the sampling distribution
in closed form. It powers confidence intervals on medians, ratio metrics, and classifier
scores, and it complements (rather than replaces) classical
hypothesis tests.
This guide explains the core algorithm, percentile vs bias-corrected accelerated (BCa)
intervals, paired vs independent resampling, a Harbor Analytics checkout A/B worked example,
a method decision table, common pitfalls, and a production checklist.
What bootstrap resampling is
Given a dataset of n observations, the bootstrap treats that sample as a stand-in for the unknown population. You draw n observations with replacement from the sample, compute a statistic of interest (mean, median, difference in proportions, F1 score), and repeat thousands of times. The empirical distribution of those replicate statistics approximates the sampling distribution of the estimator.
The name comes from “pulling yourself up by your bootstraps” — you infer population behavior using only the data you already have. Bootstrap is nonparametric: it does not assume normality, though it still assumes your sample is representative and (for simple schemes) that observations are independent and identically distributed (i.i.d.).
Bootstrap is not magic. It cannot fix a biased sample, leaking labels, or a stopped-early A/B test. It estimates uncertainty conditional on the data collection process being sound.
The algorithm in four steps
- Observe data
x₁, …, xₙand compute the target statisticθ̂ = T(x)(e.g. conversion rate difference). - Resample B times: for each b = 1…B, draw
n items with replacement to form
x*ₙ. - Recompute
θ̂*ₙ = T(x*ₙ)for each replicate. - Summarize the
{θ̂*ₙ}distribution — percentiles for confidence intervals, fraction exceeding zero for one-sided tests, standard deviation for bootstrap standard errors.
Typical choices: B = 1,000 for quick dashboards, B = 10,000 for published intervals, B = 100,000+ only when tail accuracy matters and compute is cheap. More replicates tighten Monte Carlo noise in the interval endpoints, not the underlying uncertainty in your data.
Confidence intervals: percentile, BCa, and bootstrap-t
Percentile (basic) interval
Sort the B bootstrap statistics. A 95% percentile interval uses the 2.5th and 97.5th percentiles. It is simple and widely used, but can be biased when the sampling distribution is skewed — common for ratios, medians, and small samples.
BCa (bias-corrected and accelerated)
BCa adjusts percentile endpoints for bias (how far the median bootstrap
estimate sits from the original θ̂) and skewness (jackknife-based
acceleration). BCa intervals are usually more accurate for proportion differences and
correlation coefficients. Most statistical libraries (scipy.stats.bootstrap,
R boot.ci) offer BCa with modest extra compute.
Bootstrap-t
Rescale each bootstrap replicate by a bootstrap estimate of the standard error to approximate Student-t intervals. Works well when the statistic is approximately normal but the standard error formula is messy. Less common in product analytics than percentile or BCa.
Pair bootstrap intervals with point estimates and, when stakeholders need a yes/no, report whether the interval excludes the null (e.g. zero lift). That is equivalent to a two-sided test at the matching alpha, but the interval carries more information than a lone p-value.
Paired vs independent resampling
Choosing the wrong resampling scheme is the most common bootstrap mistake in production.
- Independent (two-sample) bootstrap — resample group A and group B separately. Use for classic A/B tests where each user appears in only one variant and groups are independent.
- Paired bootstrap — resample units (users, documents, sessions) and keep both measurements together. Use when the same entities are measured under two conditions: before/after on the same users, classifier A vs B on the same test set, or matched pairs.
- Cluster bootstrap — resample clusters (accounts, stores, days) when observations within a cluster are correlated. Ignoring clustering yields intervals that are too narrow and false positives.
For Harbor Analytics checkout, sessions are independent across users, so a two-sample bootstrap on conversion indicators is appropriate. If the test had measured the same logged-in users before and after the redesign, paired resampling would be required.
Worked example: Harbor Analytics checkout A/B lift
Setup. Control: 4,200 sessions, 252 conversions (6.0%). Treatment: 4,200 sessions, 344 conversions (8.19%). Observed lift: +2.19pp. Metric is Bernoulli per session; user-level clustering is negligible at this traffic level.
Procedure.
- Encode each session as 1 (converted) or 0.
- For B = 10,000 replicates: resample 4,200 control rows with replacement,
resample 4,200 treatment rows with replacement, compute
lift* = p̂*treat − p̂*ctrl. - BCa 95% interval on the 10,000 lifts:
[+0.42pp, +3.91pp]. - Fraction of replicates with lift* ≤ 0: 1.2% (one-sided bootstrap p ≈ 0.012).
Interpretation. The interval excludes zero; even conservative BCa endpoints support a positive effect. The team also checked guardrail metrics (average order value, page load) with separate bootstraps. They did not peek and restart the test mid-flight — bootstrap does not rescue invalid experimental design.
Sanity check. A two-proportion z-test gives a similar p-value (~0.011). Agreement between parametric and bootstrap methods increases trust; large disagreement signals skew, small n, or violated assumptions — prefer the bootstrap interval when in doubt.
Bootstrap for machine learning metrics
Classifier evaluation on a fixed test set is a paired problem: the same examples appear in every metric computation. The correct approach is to resample test rows with replacement and recompute precision, recall, F1, or AUC on each replicate.
- Do bootstrap at the example level (or patient level in medical data).
- Do not bootstrap across different random train/test splits in the same pipeline — that mixes variance from resampling with variance from model fitting; use nested cross-validation for model selection instead.
- Report metric point estimate plus bootstrap CI in model cards; compare models by whether CIs overlap only when effect sizes are similar.
For imbalanced labels, bootstrap CIs on PR-AUC and recall at fixed precision are often more informative than accuracy alone. See precision, recall and F1 for metric definitions.
Method decision table
| Goal | Recommended approach | When to use something else |
|---|---|---|
| CI on a mean with large n, near-normal data | Classical t-interval (cheaper) | Bootstrap still fine; use BCa if skew is visible |
| CI on median, ratio, or correlation | BCa bootstrap | Parametric delta method if you trust asymptotics |
| A/B proportion or revenue-per-user lift | Two-sample bootstrap (BCa) | Bayesian Beta-Binomial if you want priors; credible intervals |
| Before/after on same users | Paired bootstrap on differences | Independent two-sample bootstrap will anti-conservatively narrow CIs |
| Nested data (users in accounts) | Cluster bootstrap at account level | Simple bootstrap inflates false-positive rate |
| Classifier metric on fixed test set | Paired bootstrap on test examples | McNemar or DeLong for specific paired comparisons |
| Time-series forecast error | Block bootstrap (moving blocks) | Plain i.i.d. bootstrap ignores autocorrelation |
Common pitfalls
- Wrong pairing — independent bootstrap on matched-pair data produces intervals that are too narrow.
- Too few replicates — B = 100 makes percentile endpoints noisy; use at least 1,000 for 95% CIs.
- Resampling leaks — bootstrapping train and test together, or resampling after target encoding on the full dataset, smuggles label information.
- Ignoring stopping rules — peeking at A/B results and stopping when significant invalidates any interval, bootstrap included.
- Zero-variance replicates — tiny samples can yield many identical bootstrap statistics; BCa acceleration breaks; fall back to exact tests or collect more data.
- Confusing CI with prediction interval — bootstrap CI is for the population parameter (mean conversion), not the next single session outcome.
- Multiple comparisons — bootstrapping twenty metrics without correction still inflates false discoveries; apply FDR or pre-register primary metrics.
Production checklist
- Define the estimand clearly (user-level vs session-level conversion, revenue mean vs median).
- Verify experimental validity before bootstrapping (randomization, no peeking, stable exposure).
- Choose independent, paired, or cluster resampling to match the data-generating process.
- Use B ≥ 1,000 (10,000 for reporting); fix the random seed for reproducibility.
- Prefer BCa intervals for proportion differences and skewed metrics.
- Report point estimate, CI, and sample sizes — not only “significant.”
- Cross-check with a parametric test when assumptions are plausible; investigate disagreements.
- For ML, bootstrap on the held-out test set only; keep training frozen across replicates.
- Document metrics and resampling unit in experiment logs and dashboards.
- When stakes are high, pair frequentist bootstrap with Bayesian sensitivity analysis.
Key takeaways
- Bootstrap simulates sampling distributions by resampling the observed data with replacement.
- BCa intervals handle skew better than basic percentiles for lift and ratio metrics.
- Pairing matters — match the resampling unit to how the data were collected.
- ML evaluation needs example-level bootstrap on a fixed test set, not random retraining.
- Bootstrap quantifies uncertainty; it does not fix bad experiments.
Related reading
- Statistical significance and hypothesis testing explained — p-values, power, and classical confidence intervals that bootstrap complements
- A/B testing explained — experiment design, peeking traps, and when lift estimates are trustworthy
- Bayesian inference explained — credible intervals as an alternative framing for uncertainty
- Overfitting and cross-validation explained — model-selection validation separate from test-set bootstrap CIs