Bootstrap Confidence Interval Calculator: Percentile and BCa Intervals
By FindMySum · Last reviewed
A bootstrap calculator finds a confidence interval for a statistic by resampling your data rather than by using a formula. You paste a sample, choose the statistic (the mean, the median, the standard deviation or a proportion), and the calculator draws thousands of new samples from yours, computes the statistic for each and reads the interval off their spread. It gives the percentile interval and the more refined BCa interval, the bootstrap standard error and a histogram of the resampled values.
The resampling is driven by a seeded random number generator, so the same inputs always give the same interval and a shared link reproduces your result exactly.
The idea behind the bootstrap
A confidence interval needs to know how much a statistic would change if you could repeat the study many times. Classical methods get that from a formula: the standard error of a mean is s/√n. For many statistics, such as the median, a trimmed mean, a correlation or a ratio, there is no simple formula, or the formula relies on assumptions (normality, large samples) that your data may not meet.
The bootstrap's answer is to let the sample stand in for the population. If your sample is representative, drawing from it with replacement behaves like drawing new samples from the population. Repeat that B times, compute the statistic each time, and the B results form the bootstrap distribution: an estimate of the statistic's sampling distribution.
Step by step
- Compute the statistic θ̂ on your n values.
- Draw a resample: n values chosen at random from your data, with replacement.
- Compute the statistic on the resample. Repeat steps 2 and 3 B times.
- The standard deviation of the B results is the bootstrap standard error. Their mean minus θ̂ estimates the bias.
- Read the interval from the sorted results.
Percentile and BCa intervals
The percentile interval is the simplest: for 95% confidence, take the 2.5th and 97.5th percentiles of the bootstrap distribution. It works well when the bootstrap distribution is roughly symmetric and centred on θ̂.
The BCa interval (bias-corrected and accelerated, Efron 1987) adjusts which percentiles are used. The bias correction z₀ comes from the share of bootstrap values below θ̂: if more than half fall below, the statistic is biased upward and the interval shifts. The acceleration a, worked out with the jackknife, corrects for a standard error that changes with the true parameter, which shows up as skewness. The adjusted percentiles are Φ(z₀ + (z₀ + z_α)/(1 − a(z₀ + z_α))), where z_α is the normal quantile. When z₀ and a are both 0, BCa reduces to the percentile interval.
Both are shown, because both are in common use. BCa is generally more accurate, especially for skewed statistics such as the standard deviation, but it needs more resamples to be stable and is undefined when every resample lands on the same side of θ̂, as with constant data.
The calculator reads percentiles the way R's boot package does: the value at position (B + 1) × p of the sorted results, interpolating between neighbours on the normal-quantile scale. Other software may use a slightly different percentile rule and give endpoints that differ in the last digits.
Worked example: mouse survival times
The calculator opens with the treatment group of a small experiment from Efron and Tibshirani's book: survival times of 7 mice, 94, 197, 16, 38, 99, 141 and 23 days. Their mean is 86.86 days.
- Resample: with seed 12345 the first resample has a mean of 83.0 days, the next 92.6, the next 120.7.
- Repeat: 2,000 resamples give a bootstrap standard error of about 24.0 days. The formula s/√n gives 25.2, and the bootstrap's theoretical limit for a mean, s/√n × √((n − 1)/n), is 23.4.
- Interval: the 95% percentile interval runs from about 43.1 to 136.8 days; the BCa interval from about 44.3 to 138.5.
With only 7 values the interval is wide, as it should be, and the two methods differ slightly because the data are skewed by the 197.
How many resamples?
Efron and Tibshirani suggest 50 to 200 resamples for a standard error and at least 1,000 for an interval, because percentiles in the tails need many values to settle. The default here is 2,000. To see how much your endpoints depend on chance, change the seed: if the interval moves in a digit you care about, increase B.
When the bootstrap struggles
- Very small samples. With fewer than about 10 to 15 values the bootstrap distribution has too few distinct values and intervals tend to be too narrow.
- Extremes. The bootstrap can't estimate the maximum or minimum of a population, because a resample can never exceed the largest value in your sample.
- Dependent data. Time series and clustered data need block or cluster bootstraps; resampling single values breaks the dependence.
- Unrepresentative samples. Resampling reuses the information you have. It can't correct for a biased sample.
For a single proportion or mean of a large sample, the classical intervals on the point estimate and z-score pages are simpler and nearly identical. The bootstrap earns its keep with medians, standard deviations and other statistics without an easy formula.
More questions
Who invented the bootstrap?
Bradley Efron of Stanford University introduced it in 1979 in the Annals of Statistics paper 'Bootstrap Methods: Another Look at the Jackknife'. The name comes from the phrase 'to pull oneself up by one's bootstraps': the method estimates the variability of a statistic from the sample alone, without a formula or extra data.
Why resample with replacement?
Sampling n values from n without replacement would just reorder the data and give the same statistic every time. With replacement each resample is a different mix, some values repeated and some left out, which mimics drawing a fresh sample from a population that looks like your data.
Is a 95% bootstrap interval guaranteed to contain the true value 95% of the time?
Only approximately. The coverage approaches 95% as the sample grows. For small samples percentile intervals often cover less than the nominal level; BCa intervals were designed to correct much of that error, and Efron and Tibshirani show they are second-order accurate. Heavy tails and very small samples still cause undercoverage.
What is the jackknife, used in the BCa interval?
The jackknife recomputes the statistic n times, each time leaving out one value. How much those leave-one-out values vary, and how lopsided they are, measures how the statistic responds to the data. The BCa acceleration constant a is a scaled measure of that lopsidedness (skewness).
Can I bootstrap a difference between two groups?
Yes, by resampling each group separately and recomputing the difference each time, but this calculator handles one sample at a time. You can run it on each group to see their separate intervals; for the difference itself, a two-sample t test or a statistics package is the right tool.
Sources
This article explains how the calculator works and is general information, not financial, tax, legal or medical advice. Rules change; check the sources above or a qualified professional before you act.