Confidence Interval Calculator

Work out the 90%, 95% or 99% confidence interval for a mean from its standard deviation and sample size, for a proportion from a count, or for the difference between two groups. The calculator shows the margin of error, the standard error, the critical value and a sentence to paste into your paper.

Interval for
Population SD known?

Almost always no: the SD comes from your sample, so use the t interval.

Confidence level

Load a worked example

95% confidence interval for the mean

9.174 to 10.826

Mean 10.000 ± 0.826 (margin of error), using the t distribution with 24 df.

Mean
10.0000
Margin of error
0.8256
Standard error
0.4000
SD ÷ √n
Critical t (df 24)
2.0639
Lower bound
9.1744
Upper bound
10.8256

Report it like this

The mean was 10.00 (SD = 2.00, n = 25), 95% CI [9.17, 10.83].

How to use the calculator

  1. Pick what you are estimating: a mean, a proportion, or the difference between two groups.
  2. Enter the summary numbers. For a mean: the mean, standard deviation and sample size. For a proportion: the number of events and the sample size.
  3. Choose the confidence level. 95% is standard in most journals.
  4. Copy the result. The interval, margin of error and a report sentence update as you type.

The interval describes uncertainty from random sampling only. It does not account for bias from how participants were chosen or measured.

Formulas

Mean

x̄ ± tα/2, n−1 × s / √n

The critical t comes from Student’s t distribution with n − 1 degrees of freedom: 2.064 for n = 25 at 95%, approaching 1.960 as n grows. Use the z version (1.960) only when the population standard deviation is truly known.

Proportion (Wilson score interval)

[p̂ + z²/2n ± z√(p̂(1 − p̂)/n + z²/4n²)] / (1 + z²/n)

The Wilson interval keeps its stated coverage even for small samples and for proportions near 0% or 100%, where the textbook Wald formula, p̂ ± z√(p̂(1 − p̂)/n), can give impossible bounds or a zero-width interval (Brown, Cai and DasGupta 2001). The Clopper–Pearson exact interval inverts the binomial test and is guaranteed to cover at least the stated level, so it is wider.

Difference between two means

(x̄₁ − x̄₂) ± t × √(s₁²/n₁ + s₂²/n₂)

with Welch–Satterthwaite degrees of freedom, or a pooled SD with n₁ + n₂ − 2 degrees of freedom if you assume equal variances. This is the interval reported alongside a t-test.

Difference between two proportions

The Newcombe hybrid score method combines the two Wilson intervals: lower = d − √[(p̂₁ − l₁)² + (u₂ − p̂₂)²] and upper = d + √[(u₁ − p̂₁)² + (p̂₂ − l₂)²], where l and u are each group’s Wilson bounds. Newcombe (1998) found it the best of eleven methods compared.

Worked examples

  • Mean: mean 10, SD 2, n = 25. Standard error = 2/√25 = 0.40; critical t(24) = 2.064; margin of error = 0.826; 95% CI 9.17 to 10.83.
  • Proportion: 7 of 50 respond (14%). Wilson 95% CI 7.0% to 26.2%; exact 5.8% to 26.7%; Wald 4.4% to 23.6%.
  • Two means: 5.2 (SD 1.1, n = 20) vs 4.4 (SD 1.9, n = 25). Difference 0.80, Welch 95% CI −0.12 to 1.72.
  • Two proportions: 56 of 70 (80%) vs 48 of 80 (60%). Difference 20.0 percentage points, Newcombe 95% CI 5.2 to 33.4.

How to interpret a confidence interval

A 95% confidence interval comes from a method that captures the true value in 95% of repeated samples. In practice, read it as the range of values reasonably compatible with your data: values inside are plausible, values well outside are not.

  • If the interval for a difference excludes 0, the difference is statistically significant at the matching level (5% for a 95% interval).
  • A wide interval means an imprecise estimate. Quadrupling the sample size roughly halves the width.
  • Two groups’ intervals can overlap even when the difference between them is significant. Compare groups with the interval for the difference, not by eye.

Journals increasingly ask for estimates with confidence intervals instead of bare p-values, as Gardner and Altman argued in the BMJ in 1986. Report them like this:

The response rate was 14% (7 of 50; 95% CI 7.0% to 26.2%, Wilson method).

To choose a sample size that gives a target margin of error, use the sample size calculator.

Questions

How do I calculate a 95% confidence interval for a mean?
Divide the standard deviation by the square root of the sample size to get the standard error, multiply it by the critical t value for n − 1 degrees of freedom (about 2 for most samples, 1.96 for very large ones), then add and subtract that margin of error from the mean. For a mean of 10, SD 2 and n = 25, the interval is 10 ± 2.064 × 0.4, or 9.17 to 10.83.
How do I calculate a confidence interval for a proportion?
Enter the number of events and the sample size. The calculator uses the Wilson score interval by default, which is accurate even for small samples and extreme proportions. For 7 events out of 50, the 95% Wilson interval is 7.0% to 26.2%.
What is the margin of error?
The margin of error is half the width of a symmetric confidence interval: the critical value times the standard error. A poll result of 52% with a margin of error of 3 points has a confidence interval of 49% to 55%. Wilson and exact intervals for proportions are not symmetric, so they are reported as lower and upper bounds.
Should I use z or t for a confidence interval?
Use t whenever the standard deviation is estimated from your sample, which is almost always. The z interval assumes the population standard deviation is known exactly. With large samples the two give nearly the same result.
Which confidence interval method is best for a proportion?
The Wilson score interval is the usual recommendation because its coverage stays close to the stated level. The Clopper–Pearson exact interval never covers less than the stated level but is wider than needed. Avoid the Wald interval when there are fewer than about 5 events or non-events, or when the proportion is 0% or 100%.
What does it mean if a confidence interval includes zero?
For a difference between groups, an interval that includes zero means the data are compatible with no difference at that confidence level, so the difference is not statistically significant. It does not prove the groups are the same: a wide interval that includes zero can also include large differences.

Sources