Skip to content
simstat.com Statistics by simulation

Bootstrap confidence interval

Paste a list of numbers and choose a statistic. The tool resamples your data thousands of times and reports both a percentile and a BCa (bias-corrected and accelerated) confidence interval. Everything runs in your browser.

Separate values with commas, spaces or new lines. The example is the treatment group from Efron and Tibshirani's mouse survival data (days).

Leave the seed blank for a new random run. Enter the seed shown with a result to repeat that run exactly.

Result

Histogram of bootstrap replicates (run the tool to draw it)
Bars: bootstrap replicates. Shaded band: percentile interval. Orange dashed lines: BCa interval. Dark line: the statistic in your sample.

What this tool does

The bootstrap treats your sample as a stand-in for the population. It draws a new sample of the same size from your data with replacement and computes the statistic on it. Repeating that thousands of times gives the bootstrap distribution, an estimate of how much the statistic varies from sample to sample. Its standard deviation is the bootstrap standard error.

The formulas

For B replicates θ̂*, the percentile interval at level 1 − α takes their α/2 and 1 − α/2 quantiles:

[θ^(α/2)*,θ^(1−α/2)*]

BCa uses the same replicates but moves those two percentiles to α₁ and α₂:

α1=Φ(z^0+z^0+zα/21−a^(z^0+zα/2))

α₂ is the same with z1−α/2. The bias correction ẑ₀ = Φ⁻¹(share of replicates below θ̂). Ties count as not below: a replicate equal to θ̂ is not counted, as in R's boot package; some sources count ties as below (≤), which gives a slightly larger ẑ₀ when many replicates equal θ̂. The acceleration is â = Σd³ / (6(Σd²)3/2), where di = θ̂(·) − θ̂(i) is the mean of the jackknife (leave-one-out) values minus each one, as in Efron and Narasimhan (2020), eq. 3.12. Their paper prints the differences the other way round, which would flip the sign of â, but their own bcaboot R package and R's boot compute them as here. The book treatment is Efron and Tibshirani's An Introduction to the Bootstrap (1993), ch. 14. Quantiles are interpolated as in R's boot package. Because the tool uses this jackknife estimate of â, BCa results for the median and SD can differ slightly from R's boot.ci defaults, which estimate it by regression.

When the two intervals differ

If the bootstrap distribution is centred on your estimate and roughly symmetric, ẑ₀ and â are near zero and the two intervals almost coincide. They part company when the statistic is biased or its spread changes with its value, as with standard deviations and skewed data. BCa then shifts the interval, and it is usually the more accurate of the two. With fewer than about 15 values, both tend to be too narrow; the median of a small sample gives a lumpy distribution.