Statistics

What Is a Confidence Interval? Meaning, Formula and Examples

A confidence interval gives a range of plausible values for a population mean or percentage. See the formula, a step-by-step worked example, a live simulation and common mistakes.

Confidence interval bars around a dashed true-mean line, with two intervals that miss shown in red

You time your phone’s battery on ten full charges and get an average of 14.72 hours. That’s one number from one batch of tests. Run ten more and you’d get a slightly different average. So how sure can you be about the real typical battery life? A confidence interval answers that with a range: “somewhere between 14.15 and 15.29 hours, at 95% confidence.”

In short, a confidence interval is a range of plausible values for an unknown population number, such as a mean or a percentage, built from sample data. It is written as estimate ± margin of error, and the confidence level (often 95%) tells you how often the method catches the true value over many samples.

  • Formula for a mean: x̄ ± t × (s ÷ √n)
  • Most common level: 95%, with 90% and 99% also widely used
  • Wider interval: higher confidence, more spread in the data, or a smaller sample
  • Biggest misreading: “95% chance the true mean is in this interval.” That’s not quite what it means (see below)
CIFree tool: Confidence Interval CalculatorEnter your mean, standard deviation and sample size to get the interval instantly.Try it →

Worked Example: How Long Does the Battery Really Last?

The numbers here are illustrative. Ten full charges of the same phone gave these battery times, in hours:

14.2, 15.1, 13.8, 16.0, 14.9, 15.5, 13.6, 14.8, 15.3, 14.0

Here is the whole calculation for a 95% confidence interval, one line at a time.

StepWhat you calculateResult
1. Sample mean (x̄)147.2 ÷ 1014.72 h
2. Sample standard deviation (s)√(5.656 ÷ 9)0.793 h
3. Standard error0.793 ÷ √100.251 h
4. Critical value (t)95% level, 9 degrees of freedom (n − 1)2.262
5. Margin of error2.262 × 0.2510.567 h
6. Interval14.72 ± 0.56714.15 h to 15.29 h

Step 2 uses the usual sample standard deviation: the squared distances from 14.72 add up to 5.656, and you divide by n − 1 = 9 before taking the square root. Step 3 turns that spread into the standard error, which measures how much the average itself would wobble from one batch of ten tests to the next.

The critical value 2.262 comes from the t table. The NIST table of t critical values lists it in the 0.975 column for 9 degrees of freedom (0.975 because a 95% interval leaves 2.5% in each tail).

So the honest summary isn’t “the battery lasts 14.72 hours”. It’s “the typical battery life is probably somewhere between about 14.2 and 15.3 hours, based on ten tests.”

The Formula, Piece by Piece

Every confidence interval has the same shape: estimate ± (critical value × standard error). The part after ± is the margin of error. What changes is which estimate and which critical value you use.

SituationFormulaCritical value from
Mean, population σ unknown (the usual case)x̄ ± t × s ÷ √nt table, n − 1 degrees of freedom
Mean, population σ knownx̄ ± z × σ ÷ √nNormal (z) table: 1.645, 1.96 or 2.576
Proportion (polls, yes/no data)p̂ ± z × √(p̂(1 − p̂) ÷ n)Normal (z) table

The NIST/SEMATECH e-Handbook gives the mean version with the t distribution, since in real life you almost never know the population standard deviation and have to estimate it from the sample. With large samples the t value gets close to the z value anyway: for 99 degrees of freedom it’s 1.984, against 1.96 for z.

If you want to see where 1.96 comes from, our guide on how to read a z table shows it: 95% of a normal distribution sits within 1.96 standard deviations of the mean.

What “95% Confident” Actually Means

This is the part most people get slightly wrong. Once you’ve calculated 14.15 to 15.29 hours, the true average battery life is either inside that range or it isn’t. There’s no 95% chance left in that one interval.

The 95% describes the method. If you repeated the whole thing (ten new charges, a new interval) again and again, about 95 out of every 100 intervals would contain the true mean, and about 5 would miss it. NIST puts it the same way: the confidence level is the proportion of intervals, over many samples, that can be expected to contain the true mean.

The simulation below lets you watch this happen. It draws samples of 10 from a population whose true mean is set to 15 hours, builds an interval from each one, and colours the misses red.

Confidence level:
This draw–
Running total–
Hit rate so far–

Each bar is one sample of 10 from a population with true mean 15 h and SD 0.8 h, using x̄ ± t × s ÷ √10 (t = 1.833, 2.262 or 3.250). Simulated data.

Press the button a few times and you'll notice the hit rate bounces around (18 out of 20 one time, 20 out of 20 the next) but settles close to the confidence level as the running total grows. Switch to 99% and the bars get longer and misses become rare. Switch to 90% and the bars get shorter, but you see more red. That trade-off is the whole story of confidence levels.

What Makes an Interval Wider or Narrower

Three things control the width: how confident you want to be, how spread out the data is, and how much data you have. Here's the battery example at three confidence levels, with the same ten tests:

Confidence levelt (9 df)Margin of errorInterval
90%1.833± 0.46 h14.26 to 15.18 h
95%2.262± 0.57 h14.15 to 15.29 h
99%3.250± 0.81 h13.91 to 15.53 h

And here's what happens if you keep the same spread (s = 0.793 h) but test more charges:

Number of tests (n)Standard errort at 95%Margin of error
100.2512.262± 0.57 h
250.1592.064± 0.33 h
1000.0791.984± 0.16 h

Because of the √n in the formula, you need about four times as much data to cut the margin of error roughly in half. Going from 10 to 100 tests shrinks it from ±0.57 to ±0.16 hours. That's why big surveys are expensive: the last bit of precision costs the most. The size of your sample matters, but so does how it's chosen, which is covered in our guide to random sampling.

Confidence Interval for a Percentage (Polls)

News reports of polls are confidence intervals in disguise. Say 540 of 1,000 randomly chosen people answer "yes" to a question.

p̂ = 540 ÷ 1000 = 0.54
standard error = √(0.54 × 0.46 ÷ 1000) = 0.0158
margin of error = 1.96 × 0.0158 = 0.031
95% interval = 0.54 ± 0.031 → 50.9% to 57.1%

That's where "54%, with a margin of error of ±3 points" comes from. Notice that the whole interval sits above 50%, so the poll gives reasonable evidence that a majority says yes. If the interval had been 48% to 60%, you couldn't say that.

Confidence Intervals and Hypothesis Tests

A 95% confidence interval and a two-tailed hypothesis test at α = 0.05 tell the same story from different angles. If a claimed value falls outside the interval, the test would reject it. If it falls inside, the test wouldn't.

Suppose the phone maker advertises 16 hours. That's outside 14.15 to 15.29, so your ten tests are evidence against the advert. A claim of 15 hours sits inside the interval, so your data can't rule it out. Many statisticians prefer reporting the interval, because it shows the size of the effect and the uncertainty together, not just a yes/no verdict.

Common Mistakes to Avoid

  • Saying "95% probability the true value is in this interval". The 95% belongs to the method over many samples, not to one finished interval.
  • Thinking 95% of the data falls inside. The interval is about the average, not individual values. Several of the ten battery tests (13.6, 13.8, 16.0 hours) sit outside 14.15 to 15.29, and that's normal.
  • Using z when you should use t. With a small sample and an estimated standard deviation, z = 1.96 makes the interval too narrow. For n = 10 the correct t value is 2.262.
  • Ignoring how the sample was collected. No formula fixes a biased sample. If you only tested the battery with the screen dimmed, the interval is precise about the wrong thing.
  • Comparing two groups by checking whether their intervals overlap. Overlapping intervals don't automatically mean "no difference". Compare the groups with a proper test or an interval for the difference.

Frequently Asked Questions

What is a confidence interval in simple terms?

It's a range of values that probably contains the true number you're trying to estimate, such as an average or a percentage. Instead of giving one best guess, it shows the guess plus how uncertain it is, for example "14.72 hours, give or take 0.57".

Why is 95% the most common confidence level?

It's a convention that balances two goals: catching the true value most of the time while keeping the interval narrow enough to be useful. NIST notes that 90%, 95% and 99% are all common, with 95% used most often. Pick the level before you look at the result.

Is a narrower confidence interval better?

A narrower interval means a more precise estimate, which is usually what you want. But you shouldn't narrow it by lowering the confidence level after the fact. The honest way to get a narrower interval is more data or less noisy measurements.

What is the difference between a confidence interval and a margin of error?

The margin of error is the "±" part. The confidence interval is the full range you get when you add and subtract it from the estimate. A poll at 54% with a ±3.1-point margin of error has a confidence interval of 50.9% to 57.1%.

How do I calculate a 95% confidence interval quickly?

For a mean, find the sample mean, the standard deviation and the sample size, then compute mean ± t × (s ÷ √n), using the t value for n − 1 degrees of freedom. Our confidence interval calculator does all of this from those three numbers.

Can a confidence interval be wrong?

Yes. A 95% method misses the true value about 1 time in 20, and you can never tell from a single interval whether yours is one of the misses. That's why repeated studies, and bigger samples, matter.

Conclusion

A single average hides how much it could change with another sample. A confidence interval puts that uncertainty on display: estimate ± margin of error, with a confidence level describing how reliable the method is over the long run. Ten battery tests gave 14.15 to 15.29 hours; a hundred would pin it down to about a third of an hour either side.

Next time you see "±3 points" under a poll or an error bar on a chart, read it as a range, not a decoration, and ask how big the sample behind it was.

References

  • NIST/SEMATECH, "e-Handbook of Statistical Methods: Confidence Limits for the Mean" (section 1.3.5.2). itl.nist.gov
  • NIST/SEMATECH, "e-Handbook of Statistical Methods: Critical Values of the Student's t Distribution" (section 1.3.6.7.2). itl.nist.gov

Disclaimer

This article is for general educational purposes only. The battery tests and the poll figures are illustrative examples, not real product or survey data. For research design or published studies, consult a qualified statistician.

Written by

Farzan Khan writes Helinika's statistics, math and science guides. He explains each idea with a worked example and a plain-English answer first, and pairs statistics topics with Helinika's free calculators so readers can check the numbers themselves.