StatGardenREF. DESK
Calculators/Statistics/Confidence interval for a mean
Statistics

Confidence interval for a mean calculator

Margin of error around a sample average.

What this calculator does

A sample mean is an estimate, and a confidence interval expresses how precise that estimate is. Rather than reporting a single number, it gives a range along with a statement about how often such ranges capture the true value.

The interpretation is subtler than it first appears. A 95 per cent confidence interval does not mean there is a 95 per cent chance the true mean lies inside this particular range. It means that if you repeated the sampling many times, 95 per cent of the intervals produced would contain it. The distinction matters, and it is widely misstated.

The formula

FormulaCI = x̄ ± z·(s/√n) with z = 1.645 (90%), 1.96 (95%), 2.576 (99%)

The standard error, standard deviation divided by the square root of the sample size, measures how much the sample mean would vary between samples. Multiplying it by the critical value for the chosen confidence level gives the margin of error, which is then applied either side of the mean.

TermMeaning
Margin of errorCritical value × standard error.
Standard errorStandard deviation ÷ √n.
Critical value1.645 for 90%, 1.96 for 95%, 2.576 for 99%.
Confidence levelThe proportion of such intervals that would contain the true mean.

The inputs explained

FieldWhat to enter
Sample meanThe mean of your sample.
Standard deviationThe standard deviation of your sample.
Sample sizeThe number of observations. Larger samples give narrower intervals.
Confidence levelThe confidence level. Higher levels give wider intervals: more certainty requires more room.

When to use it

Reporting a survey result

A mean with a margin of error is far more informative than a mean alone, and it is the standard convention in published research.

Deciding whether two groups differ

If the intervals for two groups do not overlap, the difference is likely real. Overlapping intervals do not necessarily mean no difference, though: a formal test is needed for that.

Planning a sample size

The line showing the sample needed to halve the margin makes the trade-off concrete: four times the data for twice the precision.

Choosing a confidence level

Compare 90, 95 and 99 per cent. Higher confidence buys certainty at the cost of a wider, less useful interval.

Worked examples

Every figure in the tables below is produced by this page’s own calculator at build time, so the numbers and the tool always agree. Select any row to load that scenario.

How sample size narrows the interval

The same sample statistics at increasing sample sizes.

Mean 52.4, SD 8.2, 95% confidence
Sample sizeConfidence intervalMargin of errorRelative margin
n = 1047.318 to 57.482± 5.0829.70%
n = 3049.466 to 55.334± 2.9345.60%
n = 6050.325 to 54.475± 2.0753.96%
n = 12050.933 to 53.867± 1.4672.80%
n = 50051.681 to 53.119± 0.71881.37%
n = 200052.041 to 52.759± 0.35940.686%
Precision improves with the square root of the sample size, so going from 120 to 500 observations, more than four times the data, only halves the margin. This is why large surveys hit diminishing returns.

The cost of higher confidence

A fixed sample at each of the three standard confidence levels.

Mean 52.4, SD 8.2, n = 120
Confidence levelConfidence intervalMargin of errorRelative margin
90%51.169 to 53.631± 1.2312.35%
95%50.933 to 53.867± 1.4672.80%
99%50.472 to 54.328± 1.9283.68%
Moving from 90 to 99 per cent confidence widens the margin by more than half. Certainty is not free: it is paid for in precision.

Questions

What does a 95 per cent confidence interval actually mean?

That if you repeated the sampling process many times and computed an interval each time, about 95 per cent of those intervals would contain the true population mean. It is a statement about the procedure, not about this particular interval.

Why does a higher confidence level give a wider interval?

Because capturing the true value more often requires casting a wider net. A 100 per cent confidence interval would have to span every possible value, which is why it would be useless.

How large a sample do I need?

It depends on the precision you want and the variability in your data. Halving the margin of error requires four times the sample. The sample size calculator works this out directly for proportions.

Should I use z or t?

This calculator uses z critical values, which are appropriate for large samples or a known population standard deviation. For small samples, under about 30, with an estimated standard deviation, the t-distribution gives slightly wider and more honest intervals.

What if my intervals overlap?

Overlapping intervals do not prove that two groups are the same. A direct test of the difference is more powerful than comparing intervals by eye, and can find significance even when intervals overlap somewhat.

For survey sizing, use the sample size calculator. For summarising the sample itself, see descriptive statistics.