Confidence interval calculator
This confidence interval calculator gives a z or t interval for a population mean, or the Wilson and Wald intervals for a proportion. Enter summary statistics or paste your raw data, pick 90%, 95%, 99% or any other level, and it shows the interval, the margin of error and every step of the calculation. Everything runs in your browser.
Result
- Estimate
- –
- Margin of error
- –
- Standard error
- –
- Critical value
- –
| Method | Lower | Upper | Margin |
|---|---|---|---|
| Wilson score (recommended) | |||
| Wald |
Step by step
Numbers are rounded for display; the calculation keeps full precision. For skewed data, a small sample or a statistic other than the mean, try our bootstrap confidence interval tool, which makes no normality assumption.
How to calculate a 95% confidence interval
A confidence interval is an estimate plus or minus a margin of error. To construct the confidence interval for the population mean by hand:
- Compute the sample mean x̄ and, unless the population standard deviation σ is known, the sample standard deviation s.
- Divide the standard deviation by √n to get the standard error, the standard deviation of x̄ across repeated samples.
- Find the critical value: for 95%, z = 1.96 from the normal distribution (our normal CDF calculator gives it for any level, and our table of z-scores for confidence intervals lists the common ones), or t from the t distribution with n − 1 degrees of freedom.
- Multiply the critical value by the standard error. This is the margin of error.
- Subtract it from x̄ and add it to x̄. Those are the lower and upper limits.
For another level, replace 95% by 1 − α and use the 1 − α/2 quantile: α = 0.10 for 90%, 0.01 for 99%.
z or t
Use the z interval only when σ comes from outside the sample, such as a measuring process with a long, documented record. Illowsky and Dean (2023) give it for the case "when the population standard deviation σ is known". When s estimates σ from the same data, that extra uncertainty widens the interval, and "the practice now is to use the Student's t-distribution whenever s is used as an estimate for σ" (Illowsky and Dean, 2023). The difference matters most in small samples: at 95%, t is 2.57 with 5 degrees of freedom and 2.04 with 30, against z = 1.96.
Worked example
Worked example: t interval and proportion intervals
Take the 12 values 5.1, 4.9, 6.2, 5.8, 6.0, 5.5, 5.3, 6.4, 4.7, 5.9, 5.6, 6.1. Then x̄ = 5.625, s = 0.538 and the standard error is s/√12 = 0.155. With 11 degrees of freedom, t = 2.201, so the margin of error is 2.201 × 0.155 = 0.342 and the 95% interval is 5.283 to 5.967.
For a proportion, take x = 7 successes in n = 30 trials: p̂ = 0.233 and z = 1.960. The Wald standard error is 0.077, giving 0.082 to 0.385. The Wilson interval is centred on 0.264, pulled towards 0.5, and runs from 0.118 to 0.409. With only 7 successes (below 10), the calculator flags the Wald result.
These are the calculator's default inputs: choose "One proportion" and "Summary statistics" for the second part.
Wald or Wilson for a proportion
The Wald interval is the textbook formula, but Brown, Cai and DasGupta (2001) showed that "the chaotic coverage properties of the Wald interval are far more persistent than is appreciated". With a true proportion of 0.5, a nominal 95% Wald interval covers it about 95% of the time at n = 17 (95.1% by exact binomial calculation) but only 91.9% at n = 40: coverage does not simply improve as n grows. For small n they recommend the Wilson or Jeffreys interval, and for larger n the Agresti–Coull interval, the three then being very similar. The calculator reports Wilson, which does well at every n. The Wilson interval, which they trace to Wilson (1927), inverts the score test: it uses the standard error at the hypothesised proportion rather than at p̂. It stays inside 0 to 1 and does not collapse to a point when x = 0 or x = n, where the Wald standard error is 0.
The calculator flags the Wald interval when np̂ or n(1 − p̂) is below 10, the stricter form of a textbook rule ("are ≥ 5 (or 10)") that Brown, Cai and DasGupta list. They also show that passing such a rule does not guarantee good coverage, which is why the calculator recommends Wilson.
What the confidence level means
The 95% describes the method, not one interval. In the words of the NIST/SEMATECH e-Handbook, "The interval computed from a given sample either contains the true mean or it does not"; if many samples were taken, "in the long run about 95 % of these intervals would contain the true mean". A higher level gives a wider interval. Our guide on how to interpret confidence intervals shows this with 10,000 simulated intervals and lists the common misreadings.
Assumptions
- The data are a random sample, and observations are independent.
- For the mean, the t interval assumes the population is normally distributed (Illowsky and Dean, 2023). In larger samples the central limit theorem makes the sample mean approximately normal anyway (our sampling distribution simulator shows how fast), so mild departures matter less; with strong skew or outliers and few values, try the bootstrap instead.
- For a proportion, each observation is a success or a failure with the same probability.
References
- Brown, L. D., Cai, T. T. & DasGupta, A. (2001). Interval estimation for a binomial proportion. Statistical Science, 16(2), 101–133. doi.org/10.1214/ss/1009213286
- Illowsky, B. & Dean, S. (2023). Introductory Statistics 2e, sections 8.1 and 8.2. OpenStax.
- NIST/SEMATECH. e-Handbook of Statistical Methods, section 1.3.5.2, Confidence limits for the mean. itl.nist.gov