Confidence Interval Calculator

Enter your sample size, mean and standard deviation to get the margin of error and the confidence interval for the true average.

Quick answer. A confidence interval is the sample mean plus or minus a margin of error. With 50 checkout waits averaging 20.6 minutes (SD 3.2), the 95% interval is 19.713 to 21.487 minutes, a margin of error of 0.887.

What a confidence interval is really saying

You measured a sample, not everyone. The sample mean is your best single guess for the true average of the whole group, but it will not be exactly right. A confidence interval puts a range around that guess. A 95% interval means that if you repeated the whole sampling process many times, about 95 out of 100 of the intervals built this way would contain the true mean. Strictly, the 95% describes the method, not one particular interval. In everyday use, read it as “the true value is probably somewhere in here”. A higher confidence level gives a wider range.

The formula

CI = x̄ ± (critical value) × s ÷ √n. The part s ÷ √n is the standard error, and the critical value (z or t) times the standard error is the margin of error. Add and subtract it from the sample mean to get the lower and upper bounds.

Worked example with the default numbers

Say you timed 50 customers at a checkout. The average wait was 20.6 minutes with a standard deviation of 3.2. The standard error is 3.2 ÷ √50 = 0.4525. For a 95% interval the z-value is 1.96, so the margin of error is 1.96 × 0.4525 = 0.887 minutes, and the interval runs from 19.713 to 21.487 minutes. In plain words: the typical wait across all customers is probably between about 19.7 and 21.5 minutes. The calculator also draws this as an error bar, with the sample mean as the dot.

Margin of error by confidence level (n = 50, mean 20.6, SD 3.2)Going from 90% to 99% confidence widens the margin from 0.744 to 1.166, because the critical value rises from 1.645 to 2.576.Margin of error by confidence level (n = 50, mean 20.6, SD 3.2)80% confidence±0.58090% confidence±0.74495% confidence±0.88799% confidence±1.166
A more confident statement needs a wider range.

z or t: choosing the right critical value

The calculator uses the z-value by default, which is correct when the population standard deviation is known or the sample is large (30 or more is the common rule of thumb). With a small sample where you only have the sample standard deviation s, the t-distribution is better. It gives a larger critical value, so the interval is wider and more honest about the extra uncertainty. For example, with 10 values a 95% interval uses t = 2.262 instead of 1.96, which makes the margin of error about 15% larger (2.289 instead of 1.983 for SD 3.2). Even for the default n = 50, t = 2.010 gives a margin of 0.909 instead of 0.887. Tick the t-distribution box to see the difference on your own numbers.

Critical value at 95% confidence: t by sample size (z = 1.960)For n = 5 the t value is 2.776, more than double z, so small samples need much wider intervals. By n = 100 it is almost equal to z.Critical value at 95% confidence: t by sample size (z = 1.960)n = 52.776n = 102.262n = 202.093n = 302.045n = 502.010n = 1001.984
The t value approaches z as the sample grows.

How to make the interval narrower

  • Lower the confidence level. The z-values for 90%, 95% and 99% are 1.645, 1.960 and 2.576. A tighter range is less certain.
  • Collect more data. The margin shrinks with the square root of the sample size, so halving it takes four times as many observations.
  • Reduce variability in how you measure, where you can.
Margin of error at 95% confidence by sample size (SD 3.2)Four times as many observations halves the margin: 0.627 at n = 100 against 0.314 at n = 400.Margin of error at 95% confidence by sample size (SD 3.2)n = 10±1.983n = 25±1.254n = 50±0.887n = 100±0.627n = 200±0.443n = 400±0.314
More data is the only way to be both confident and precise.

If you are still planning a study, the Sample Size Calculator works backward from the margin of error you want to the number of observations you need.

Does the 95% really work?

In a simulation with a fixed seed, 10,000 samples of 50 were drawn from a population with a true mean of 20 and a standard deviation of 3.2, and a 95% t-interval was built from each. The true mean fell inside 95.0% of them, close to the promised 95%. The simulation is an illustration of the method, not of your data.

Getting the inputs from your data

If you have raw numbers, paste them into the Statistics Calculator or the Standard Deviation Calculator and copy the count, mean and sample standard deviation across. To see where 1.96 comes from, the Z-score Calculator converts a confidence level into its z-value: 95% leaves 2.5% in each tail.

What this calculator does not cover

  • It is the interval for a mean, not a proportion. For a proportion, such as 52% of 1,000 voters, the formula is p ± z × √(p(1 − p) ÷ n), which gives ±3.1 points.
  • It assumes a random sample and roughly bell-shaped data or a large enough sample. A confidence interval cannot fix a biased sample: if you only asked people who were easy to reach, the interval will be neatly centred on the wrong answer.
  • For samples smaller than 30 the calculator shows a reminder to consider the t-distribution.

Common mistakes

  • Reading 95% as “a 95% chance that the true mean is inside this exact interval”.
  • Using z with a small sample when only s is known.
  • Entering the standard error where the standard deviation is expected.
  • Treating overlapping intervals as proof of no difference.

How to read your result

The large line shows the mean plus or minus the margin of error, with the lower and upper bounds underneath. The steps line shows exactly which numbers were used. If the interval is too wide to be useful, the table of options above shows what to change.

A confidence interval describes sampling uncertainty only. It does not account for bias, measurement error or a non-random sample.

What to do next

Common questions

How do you calculate a confidence interval?

Take the sample mean and add and subtract the margin of error. The margin of error is the critical value (z or t) times the standard deviation divided by the square root of the sample size.

What is the z-value for a 95% confidence interval?

It is 1.96. For 90% it is about 1.645 and for 99% it is about 2.576.

What does a 95% confidence level mean?

It means the method used would capture the true mean in about 95 out of 100 repeated samples. A higher level gives a wider interval.

When should I use the t-distribution instead of z?

Use t when the sample is small, usually under 30, and you only know the standard deviation from the sample. For large samples the two give almost the same answer.

How does sample size affect the margin of error?

A larger sample gives a smaller margin of error. Because of the square root, you need four times the sample size to halve the margin.

Can I use this for a percentage, like a poll result?

Not directly. This is for a mean. For a proportion the formula is p plus or minus z times the square root of p(1 - p) divided by n.

Sources: NIST/SEMATECH e-Handbook: What are confidence intervals?; NIST/SEMATECH e-Handbook: Critical values of the Student's t

More Math Calculators

Pick another tool to jump straight to it.