Bootstrap Confidence Interval Calculator

Estimate CIs via resampling.

Examples:

Uses quantiles of bootstrap distribution directly

Use same seed for reproducible results

Enter data and click 'Run Bootstrap' to calculate CI

Use bootstrap confidence intervals when you can't assume normality, have small samples, or need intervals for complex statistics like medians, ratios, or percentiles. Bootstrap resampling makes no distributional assumptions.

What Is Bootstrapping?

Bootstrapping creates many resampled datasets by drawing with replacement from your original data, then calculates your statistic on each resample:

  1. Original sample: n observations
  2. Draw n observations with replacement β†’ Bootstrap sample 1
  3. Calculate statistic on bootstrap sample 1
  4. Repeat B times (typically 1000-10000)
  5. Use the distribution of bootstrap statistics for inference

Bootstrap CI Methods

Percentile Method

The simplest approach: use percentiles of the bootstrap distribution.

CI95%=[B0.025,B0.975]CI_{95\%} = [B_{0.025}, B_{0.975}]

Where BpB_{p} is the p-th percentile of bootstrap statistics.

Pros: Simple, intuitive Cons: Can be biased, poor coverage for skewed distributions

Basic (Reverse Percentile) Method

CI95%=[2ΞΈ^βˆ’B0.975,2ΞΈ^βˆ’B0.025]CI_{95\%} = [2\hat{\theta} - B_{0.975}, 2\hat{\theta} - B_{0.025}]

Where ΞΈ^\hat{\theta} is the original sample estimate.

Reflects the bootstrap distribution around the original estimate.

Bias-Corrected and Accelerated (BCa)

The gold standard for bootstrap CIs:

CIBCa=[BΞ±1,BΞ±2]CI_{BCa} = [B_{\alpha_1}, B_{\alpha_2}]

Where: Ξ±1=Ξ¦(z0+z0+zΞ±/21βˆ’a(z0+zΞ±/2))\alpha_1 = \Phi\left(z_0 + \frac{z_0 + z_{\alpha/2}}{1 - a(z_0 + z_{\alpha/2})}\right)

Ξ±2=Ξ¦(z0+z0+z1βˆ’Ξ±/21βˆ’a(z0+z1βˆ’Ξ±/2))\alpha_2 = \Phi\left(z_0 + \frac{z_0 + z_{1-\alpha/2}}{1 - a(z_0 + z_{1-\alpha/2})}\right)

  • z0z_0 = bias correction (proportion of bootstrap estimates below original)
  • aa = acceleration (measures skewness)

Pros: Best coverage, handles bias and skewness Cons: Computationally intensive, requires more bootstrap samples

Studentized (Bootstrap-t)

CI=[ΞΈ^βˆ’t1βˆ’Ξ±/2βˆ—β‹…SE,ΞΈ^βˆ’tΞ±/2βˆ—β‹…SE]CI = [\hat{\theta} - t^*_{1-\alpha/2} \cdot SE, \hat{\theta} - t^*_{\alpha/2} \cdot SE]

Uses the distribution of studentized statistics: tβˆ—=ΞΈ^βˆ—βˆ’ΞΈ^SEβˆ—t^* = \frac{\hat{\theta}^* - \hat{\theta}}{SE^*}

Requires estimating SE for each bootstrap sample.

Example: Bootstrap CI for Median

Data: 12, 15, 18, 22, 25, 28, 45, 52 (n = 8)

Original median: 23.5

1000 Bootstrap samples give medians:

  • 2.5th percentile: 17.5
  • 97.5th percentile: 38.5

95% Percentile CI: [17.5, 38.5]

Compare to: No simple formula exists for median CI with normal theory!

How Many Bootstrap Samples?

PurposeRecommended B
Standard error200-500
Confidence intervals1000-2000
Percentile CI1000
BCa CI2000-5000
Hypothesis testing1000-10000

More samples = more precise, but diminishing returns after ~10,000.

When to Use Bootstrap CIs

Ideal Situations

  1. Non-normal data: Skewed distributions, outliers
  2. Small samples: n < 30 where CLT is questionable
  3. Complex statistics: Median, trimmed mean, ratios, percentiles
  4. No closed-form SE: Correlation differences, regression predictions
  5. Dependent data: Time series (use block bootstrap)

When NOT to Use

  1. Very small samples: n < 10 may not capture population variability
  2. Heavy tails with tiny n: Bootstrap can be unstable
  3. Simple statistics with large n: Normal theory is fine and faster

Bootstrap for Different Statistics

Mean

XΛ‰βˆ—=1nβˆ‘i=1nXiβˆ—\bar{X}^* = \frac{1}{n}\sum_{i=1}^{n} X_i^*

Bootstrap is unnecessary for large n (use normal theory), but valid for small n or non-normal data.

Median

No simple formula for median SE. Bootstrap is often the best approach:

X~βˆ—=median(X1βˆ—,...,Xnβˆ—)\tilde{X}^* = \text{median}(X_1^*, ..., X_n^*)

Correlation

rβˆ—=cor(Xβˆ—,Yβˆ—)r^* = \text{cor}(X^*, Y^*)

Bootstrap handles the non-normal sampling distribution of r.

Regression Coefficients

Resample (X, Y) pairs together:

Ξ²^βˆ—=(Xβˆ—TXβˆ—)βˆ’1Xβˆ—TYβˆ—\hat{\beta}^* = (X^{*T}X^*)^{-1}X^{*T}Y^*

Accounts for heteroscedasticity without assuming it.

Difference in Means

Resample each group separately:

Dβˆ—=XΛ‰1βˆ—βˆ’XΛ‰2βˆ—D^* = \bar{X}_1^* - \bar{X}_2^*

Valid even with unequal variances and non-normality.

Parametric vs. Nonparametric Bootstrap

Nonparametric Bootstrap

Resample from the data itself. Makes no distributional assumptions.

Parametric Bootstrap

  1. Fit a model to data (e.g., estimate ΞΌ, Οƒ)
  2. Generate samples from the fitted model
  3. Calculate statistic on each generated sample

Use when: You're confident in the distributional form but uncertain about parameters.

Block Bootstrap for Dependent Data

For time series or spatial data, observations aren't independent. Block bootstrap preserves local dependence:

  1. Divide data into overlapping blocks
  2. Resample blocks (not individual observations)
  3. Concatenate to form bootstrap sample

Block size requires tuningβ€”too small ignores dependence, too large reduces variability.

Checking Bootstrap Results

Convergence

Increase B until SE of bootstrap SE stabilizes:

SEbootstrap(SE)β‰ˆSE2BSE_{bootstrap}(SE) \approx \frac{SE}{\sqrt{2B}}

Bias

Bias=ΞΈβˆ—Λ‰βˆ’ΞΈ^\text{Bias} = \bar{\theta^*} - \hat{\theta}

If bias is large relative to SE, consider BCa method.

Normality of Bootstrap Distribution

If bootstrap distribution is highly non-normal, percentile method may have poor coverage. Use BCa.

Common Mistakes

Resampling Wrong Units

For clustered data, resample clusters, not observations. For paired data, resample pairs.

Ignoring Dependence

Standard bootstrap assumes independence. Use block bootstrap for time series.

Too Few Bootstrap Samples

B = 100 is too few for CIs. Use at least 1000.

Expecting Miracles with Tiny n

Bootstrap can't create information that isn't in your sample. With n = 5, your CI will be wide regardless.

Comparison to Other Methods

MethodAssumptionsBest For
Normal theoryNormality, large nMeans with large samples
t-intervalNormality (robust)Small sample means
BootstrapNone (IID)Complex statistics, non-normal data
BayesianPrior specificationIncorporating prior knowledge

Reporting Bootstrap Results

Standard format: "The median response time was 23.5 ms (95% BCa bootstrap CI: 17.5–38.5 ms, B = 5000)."

Include:

  • Original estimate
  • CI method (percentile, BCa, etc.)
  • Number of bootstrap samples
  • Any special considerations (block size for time series)

Computational Considerations

Efficiency Tips

  1. Vectorize operations
  2. Use parallel processing for large B
  3. Store only needed statistics, not full resamples
  4. Consider subsampling for huge datasets

Reproducibility

Set random seed before bootstrapping for reproducible results.

Historical Context

Bradley Efron introduced the bootstrap in 1979, revolutionizing statistical inference. The BCa method (1987) improved coverage properties. Advances in computing made the bootstrap practical, fundamentally changing how statisticians approach complex inference problems.

Related Calculations

Summary

Bootstrap confidence intervals work by resampling your data with replacement, computing the statistic of interest many times, and using the resulting distribution for inference. The percentile method is simplest but BCa is preferred for its better coverage properties. Use bootstrap when normality is questionable, samples are small, or for statistics without closed-form standard errors. Choose at least 1000 resamples for CIs, 2000+ for BCa. Report the method used and number of bootstrap samples.