Home / Math / Confidence Interval Calculator
Confidence Interval Calculator for a Mean or a Proportion
Turn a sample result into an interval estimate. Enter a sample mean, standard deviation and size, or a count of successes, and get the margin of error and the interval at your chosen confidence level.
What a confidence interval does and does not say
A confidence interval is a range built from sample data that is designed to capture an unknown population value. A 95% level refers to the method: if you repeated the sampling many times and built an interval each time, about 95% of those intervals would contain the true value. It does not mean there is a 95% probability that this particular interval holds the true value, because once calculated, the interval either contains it or it does not. A wider interval comes from higher confidence, a more variable sample or a smaller sample size. Quadrupling the sample size roughly halves the margin of error, since the standard error shrinks with √n.
Interval for a mean: z or t
The interval for a mean is x̄ ± critical value × s ÷ √n. The term s ÷ √n is the standard error. When the population standard deviation is known, the critical value comes from the normal distribution: 1.960 for 95%. In nearly all real work σ is unknown and estimated from the sample, which adds uncertainty, so the t-distribution with n − 1 degrees of freedom is used. It has heavier tails, so its critical values are larger, especially for small samples.
| Degrees of freedom | t for 95% |
|---|---|
| 5 | 2.571 |
| 10 | 2.228 |
| 20 | 2.086 |
| 30 | 2.042 |
| Very large | 1.960 |
The calculator holds a table of t values for 1 to 30 degrees of freedom and for 40, 50, 60, 80, 100 and 120. For other values it uses the row just below, which gives a slightly wider and therefore cautious interval. Above 120 it uses the normal value.
Interval for a proportion: Wald and Wilson
For a sample proportion p̂ = successes ÷ n, the traditional Wald interval is p̂ ± z × √(p̂(1 − p̂) ÷ n). It is simple but can perform poorly with small samples or proportions near 0 or 1, and it can spill outside the 0 to 100% range. The Wilson score interval recentres the estimate and gives better coverage, so it is shown as the headline. As a rule of thumb, the Wald interval is acceptable when both the successes and the failures number at least 10. Both are displayed, and the page warns you when the Wald assumptions look weak.
Common mistakes and limits
- Using the wrong standard deviation. Enter the standard deviation of the individual observations, not the standard error. The calculator divides by the square root of n itself.
- Applying it to biased samples. The interval reflects random sampling error only. Selection bias, poor measurement or non-response are not captured.
- Very skewed data with small samples. The t-interval assumes the sample mean is roughly normal. For small skewed samples consider a transformation or a different method.
- Overlap misreading. Two overlapping intervals do not always mean no real difference exists; test the difference directly.
- Finite populations. If the sample is a large share of a small population, a finite-population correction narrows the interval. This tool does not apply one.
For choosing n in advance, see the sample size calculator.
Worked example
A sample of 10 measurements has a mean of 100 and a sample standard deviation of 5. Find the 95% confidence interval for the true mean.
Inputs
| Interval for a | Mean |
|---|---|
| Confidence level | 95% |
| Sample mean | 100 |
| Standard deviation | 5 |
| Use | t-distribution (σ unknown, estimated by s) |
| Sample size n | 10 |
Result
95% confidence interval for the mean, margin of error ±3.5765.
| Standard error s ÷ √n | 1.58114 |
|---|---|
| t critical value, df = 9 | 2.262 |
| Margin of error | 3.5765 |
| Lower bound | 96.4235 |
| Upper bound | 103.5765 |
Accuracy note: Results use standard double-precision arithmetic, so very large or very small values may be rounded. Check important results by another method.
Frequently asked questions
How do I calculate a 95% confidence interval for a mean?
Find the standard error by dividing the standard deviation by the square root of n, multiply it by the t critical value for n minus 1 degrees of freedom, then add and subtract the product from the mean.
When should I use z instead of t?
Use z when the population standard deviation is known in advance, which is rare. Otherwise use t, which accounts for the extra uncertainty from estimating the spread from the sample itself.
What does a 95% confidence level really mean?
It means the procedure captures the true value in about 95% of repeated samples. It is a statement about the method, not a 95% chance for one computed interval.
How can I get a narrower interval?
Increase the sample size, reduce variability through better measurement, or accept a lower confidence level. Halving the margin of error needs about four times as many observations.
Why does the page show Wilson and Wald intervals?
The Wald interval is the textbook formula but can misbehave for small samples or extreme proportions. The Wilson interval keeps its coverage closer to the stated level in those cases.
Related calculators
References and sources
- NIST/SEMATECH e-Handbook of Statistical Methods: confidence intervals and the t distribution. Link
- Wilson, E. B. (1927), Probable inference, the law of succession, and statistical inference, Journal of the American Statistical Association.