Skip to content

Confidence Intervals Explained: What 95% Really Means

An estimate with a confidence range, and many repeated ranges where one misses the true value.

A single number, such as an average conversion rate or a model’s accuracy, hides how much it could have varied with a different sample. A confidence interval puts a range around the number so readers can see how precise it really is.

What a confidence interval is

A confidence interval is a range of plausible values for a quantity you are estimating, such as a population mean, calculated from a sample. If a survey finds an average of 4.2 with a 95% confidence interval from 3.9 to 4.5, the data are consistent with true averages anywhere in that range, and not just 4.2.

What “95%” actually means

The common misreading is that there is a 95% probability the true value lies inside this particular interval. The correct reading is about the method: if you repeated the whole sampling process many times and built an interval each time, about 95% of those intervals would contain the true value. Any single interval either contains it or does not. This is subtle, but it is worth getting right, because it stops you from overstating what one interval proves.

What makes an interval wider or narrower

  • Sample size. More data gives a narrower interval, though the gain slows down: halving the width takes roughly four times as much data.
  • Variability. Noisier data gives a wider interval.
  • Confidence level. A 99% interval is wider than a 95% one, because it aims to capture the true value more often.

The classic formula

For a mean, a common approximation is the sample mean plus or minus about 1.96 times the standard error, where the standard error is the sample standard deviation divided by the square root of the sample size. That uses a normal approximation, which works reasonably for moderately large samples, and for small samples a t-distribution is the better choice.

The bootstrap: an interval without a formula

The bootstrap builds an interval by resampling your own data. You draw many samples from it with replacement, compute the statistic on each, and read off the middle 95% of the results. It works for statistics that have no simple formula, such as a median or a model’s accuracy.

import numpy as np

rng = np.random.default_rng(42)
data = np.array(values)   # your observed sample

boot_means = [
    rng.choice(data, size=len(data), replace=True).mean()
    for _ in range(5000)
]
low, high = np.percentile(boot_means, [2.5, 97.5])

Here values is your list of observations. Fixing the random seed makes the result repeatable, a habit covered in random seed reproducibility.

Intervals for model performance

A test accuracy of 0.87 on a small test set could easily be 0.82 or 0.92 on another. Reporting an interval, for example from a bootstrap of the test predictions or from the spread across folds in cross-validation, shows whether a difference between two models is real or within the noise. The same applies to the error scores in regression metrics.

Intervals and experiments

In an A/B test, an interval around the difference between the two versions is more useful than a p-value alone. If it ranges from slightly negative to clearly positive, the result is inconclusive. If the whole interval sits above the smallest improvement you care about, you have good evidence the change helps. A p-value answers whether there is any difference, while an interval shows how large it might be, a framing that follows from the null hypothesis.

What intervals do not cover

A confidence interval captures random sampling variation only. It does not protect against a biased sample, a measurement error or a confounder, so a narrow interval around a biased estimate is still wrong, as discussed in correlation vs causation.

A quick checklist

  1. Do you report an interval, not just a single number?
  2. Are you describing it as a statement about the method, not a probability for this one interval?
  3. Is the sample large enough for the width you need?
  4. Did you consider the bootstrap for statistics without a formula?
  5. Have you checked for bias that an interval cannot reveal?

FAQ

What does a 95% confidence interval mean?
If you repeated the sampling and interval-building process many times, about 95% of the intervals would contain the true value. It is a statement about the method, not a 95% probability for one interval.

How do I make a confidence interval narrower?
Collect more data, reduce the variability in your measurements, or accept a lower confidence level. Larger samples help, but with diminishing returns.

What is the bootstrap?
It is a method that estimates uncertainty by repeatedly resampling your own data with replacement and recomputing the statistic each time.

Related posts

Leave a comment

Your email address will not be published. Required fields are marked *