Skip to content
K Knidox Search…
Statistics · Estimation

Bootstrap Intervals

Confidence intervals by resampling — for the median and other statistics with no formula.

Separate values with commas, spaces or newlines. At least 3 values.
StatisticThe bootstrap earns its keep on statistics with no usable formula.
Confidence
Resamples
Change it to see how much the answer moves between runs.
Observed median
10.175

from your 20 values

Bootstrap standard error
0.11921

spread of the statistic across resamples

Bias
-0.0077

resample mean minus the observed value

Method95% intervalWidthWhat it does
Percentile[9.925, 10.375]0.45The plain quantiles of the resampled statistics. Simple, and the usual first answer.
Basic[9.975, 10.425]0.45The percentile interval reflected about the observed value, correcting for bias.
BCa[9.9, 10.35]0.45Bias-corrected and accelerated. The most accurate of the three, and the one to quote when the bootstrap distribution is skewed.

The 5,000 resampled values

Distribution of the resampled statistic

9.7141skewness -0.30810.5859

The resampled distribution is close to symmetric, so the three methods largely agree. They separate when it is skewed. Results are reproducible: the same data, statistic and seed always give the same interval.

Try a shape — tap to load

The bootstrap builds a confidence interval by resampling your own data with replacement, thousands of times, and watching how much the statistic moves. It needs no formula and no distributional assumption, which is why it works for the median, the IQR and anything else without a standard error.

Using the sample as a stand-in for the population

A confidence interval asks how much a statistic would vary across repeated samples from the population. You only have one sample, and no access to the population — so the bootstrap does the obvious audacious thing and treats the sample as the population. Draw from it with replacement, the same number of values, and compute the statistic. Do that a few thousand times and the spread of those values estimates the spread you would have seen across real repeated sampling.

Drawing with replacement is the whole trick. Without it every resample would be the original data in a different order, and the statistic would never move. With it, some values appear twice and others not at all, which is exactly the kind of variation a fresh sample would have shown.

Why this matters for the median

The mean has a standard error you can write down: s ÷ √n. The median does not, in any form usable by hand — its sampling distribution depends on the population density at the median, which you do not know. The bootstrap sidesteps the problem entirely by never needing a formula, and the same applies to the interquartile range, a trimmed mean, a ratio of two statistics, or anything else you can compute.

resample with replacement → recompute → repeat B times → read the quantiles

B of 1,000 works; 10,000 makes the interval endpoints steadier

  1. 1
    Draw a resample the same size as your data. With replacement, so a value can appear more than once or not at all.
  2. 2
    Compute the statistic on it. Whatever you are estimating — the median, the standard deviation, anything.
  3. 3
    Repeat a few thousand times. The collected values form the bootstrap distribution shown on this page.
  4. 4
    Read the interval off its quantiles. The 2.5th and 97.5th percentiles give a 95% percentile interval.
  5. 5
    Prefer BCa when the distribution is skewed. It corrects for bias and for the statistic’s variance changing with its own value, which is when the three methods separate.

How often each interval really covers, normal data

Share of nominal 95% intervals containing the true mean, from 1,200 simulated samples at each size with 1,200 resamples each.

nPercentileBasicBCat interval
1090.8%90.3%90.6%94.5%
2094.8%95.3%94.5%96.6%
5094.1%93.7%94.3%94.9%

What the bootstrap cannot rescue

That table is the honest caveat. The bootstrap is an asymptotic method: its guarantees arrive as the sample grows, and at n = 10 all three intervals cover about 91% of the time while claiming 95%, where the ordinary t interval manages 94.5%. If your data is roughly normal and you want a mean, the textbook formula is simply better at small n. The bootstrap earns its place when there is no formula, or when the data is too skewed for one to apply.

It also cannot fix a sample that is not representative. Resampling reproduces whatever is in your data, biases included — if the sampling was skewed, every resample inherits the same skew and the interval will be confidently wrong. The same applies to a sample too small to contain the tail behaviour that matters: the bootstrap cannot invent values it never saw, which is why intervals for extreme quantiles are unreliable at small n.

One practical note: because the method is random, two runs give slightly different endpoints. This page seeds its generator, so the same data, statistic and seed always produce the same interval — a number you can quote. Changing the seed shows how much of the last digit is noise, which is a useful check before reporting one.

What is bootstrapping?
Estimating how much a statistic varies by resampling your own data with replacement, thousands of times, instead of relying on a formula for its standard error.
Why resample with replacement?
Without it, every resample would be the original values reordered and the statistic would never change. Replacement makes some values repeat and others drop out, which mimics the variation a fresh sample would show.
Which interval should I report?
BCa when the resampling distribution is skewed, since it corrects for bias and for changing variance. When the distribution is close to symmetric all three agree and the percentile interval is the simplest to explain.
How many resamples do I need?
1,000 is enough for a standard error, 10,000 makes the interval endpoints steady. Beyond that the extra precision is in digits you would not report.
Is the bootstrap always better than a formula?
No. For the mean of roughly normal data at small n, the t interval covers better — 94.5% against about 91% at n = 10 in the simulation above. The bootstrap wins when no usable formula exists.
Can it fix a biased sample?
No. Resampling reproduces whatever your data contains, so a sample that was not representative produces an interval that is confidently wrong. The bootstrap quantifies sampling variation, not sampling error.
Why do I get a different answer each run?
Because resampling is random. This page seeds its generator so results are reproducible; changing the seed shows how much of the final digit is noise.