Confidence interval for a mean
x ± z* × σ ÷ √n (known population σ)
Use t whenever the standard deviation comes from your own sample, which is nearly always. The t critical value is larger than z for small samples, which widens the interval to allow for the extra uncertainty. This calculator computes t* exactly for any degrees of freedom (no table lookup), so you aren't limited to the rows of a printed table.
Example: a sample of 25 has a mean of 100 and a standard deviation of 15. At 95% with 24 degrees of freedom, t* = 2.0639. The standard error is 15 ÷ √25 = 3, so the margin is 2.0639 × 3 = 6.19 and the interval is 93.81 to 106.19. With z* = 1.96 it would be slightly narrower: 94.12 to 105.88.
Confidence interval for a proportion
Wald: p̂ ± z √( p̂(1 − p̂)/n )
The Wald interval is the one in many textbooks, but it performs poorly for small samples and for proportions near 0% or 100%. It can even give a lower limit below 0. The Wilson score interval keeps close to the promised coverage in those cases, which is why statisticians (Brown, Cai and DasGupta, 2001) and the NIST handbook recommend it. For large samples with a proportion near the middle, the two agree closely.
Example: 50 yes answers out of 100 at 95%: Wilson gives 40.38% to 59.62%, and Wald gives 40.20% to 59.80%. With 0 out of 10, Wald gives the useless 0% to 0%, while Wilson gives 0% to 27.75%.
Common critical values
| Confidence | z* | t* (df = 9) | t* (df = 29) |
|---|---|---|---|
| 90% | 1.6449 | 1.8331 | 1.6991 |
| 95% | 1.9600 | 2.2622 | 2.0452 |
| 99% | 2.5758 | 3.2498 | 2.7564 |
What a confidence interval doesn't tell you
- It covers sampling error only. A biased sample, such as an online poll, can be confidently wrong.
- The t interval assumes the data is roughly normal, or that the sample is big enough (about 30 or more) for the mean to behave normally. Very skewed data needs more.
- A 95% interval doesn't mean 95% of the data lies inside it. It's about the mean, not individual values.
Sources
- NIST/SEMATECH e-Handbook: Confidence limits for the mean
- NIST/SEMATECH e-Handbook: Confidence intervals for a proportion (Wilson method)
- Brown, Cai and DasGupta (2001), Interval Estimation for a Binomial Proportion, Statistical Science 16(2)
- Wilson (1927), Probable Inference, the Law of Succession, and Statistical Inference, JASA 22