How to use the confidence interval calculator
- Choose a mean or a proportion.
- For a mean, enter the sample mean, standard deviation and sample size, and say whether ฯ is known (z) or estimated from the sample (t). For a proportion, enter the number of successes and the sample size.
- Pick a confidence level (90%, 95%, 99% or your own) and read the interval, margin of error, standard error and critical value.
Confidence interval formulas
Mean, ฯ known: xฬ ยฑ z* ร ฯ รท โn
Proportion (Wald): pฬ ยฑ z* ร โ(pฬ(1 โ pฬ) รท n)
Proportion (Wilson): [pฬ + zยฒ/2n ยฑ zโ(pฬ(1 โ pฬ)/n + zยฒ/4nยฒ)] รท (1 + zยฒ/n)
Worked examples
Mean: xฬ = 50, s = 10, n = 25, 95% confidence
Margin of error = 2.0639 ร 2 = 4.128 โ CI = 45.87 to 54.13
If ฯ = 10 were known, z* = 1.960 would give a slightly narrower 46.08 to 53.92.
Proportion: 520 of 1,000 say yes, 95% confidence
Margin of error = 1.96 ร 0.0158 = 0.031 โ 48.9% to 55.1%
Small sample: 3 of 20
The simple formula gives โ0.6% to 30.6%, an impossible negative lower bound. The Wilson interval gives a sensible 5.2% to 36.0%, which is why the calculator shows both.
Common critical values
| Confidence | z* | t* (df 10) | t* (df 30) |
|---|---|---|---|
| 90% | 1.645 | 1.812 | 1.697 |
| 95% | 1.960 | 2.228 | 2.042 |
| 99% | 2.576 | 3.169 | 2.750 |
Assumptions
- Random sample of independent observations.
- Means: the data are roughly normal, or n is large enough (often n โฅ 30) for the sample mean to be approximately normal.
- Proportions: the Wald interval needs at least about 10 successes and 10 failures; otherwise use Wilson.
Related math
The standard error uses a square root; check it by hand with the square root calculator. To draw a random sample, the random number generator can pick unique IDs. Survey results often come as ratios; convert them with the ratio calculator. More math calculators.
Sources
Frequently asked questions
How do you calculate a confidence interval?
Confidence interval = estimate ยฑ critical value ร standard error. For a mean, the standard error is s รท โn and the critical value comes from the t distribution (or z if the population standard deviation is known). With xฬ = 50, s = 10 and n = 25 at 95%: 50 ยฑ 2.064 ร 2 = 45.87 to 54.13.
What does a 95% confidence interval mean?
It means the method captures the true value 95% of the time: if you took many samples and built an interval from each, about 95% of them would contain the true population value. It doesn't mean there's a 95% chance the true value lies in this particular interval.
When should I use t instead of z?
Use t when you estimate the standard deviation from your sample, which is almost always. Use z only when the population standard deviation is genuinely known. With large samples the two give nearly the same answer: t* for 1,000 degrees of freedom is 1.962 versus z* = 1.960.
What are the critical values for 90%, 95% and 99%?
For z: 1.645 (90%), 1.960 (95%) and 2.576 (99%). For t they're larger and depend on degrees of freedom (n โ 1); for example, at 95% t* is 2.064 with 24 degrees of freedom and 12.706 with 1.
How do I calculate a confidence interval for a proportion?
pฬ ยฑ z* ร โ(pฬ(1 โ pฬ) รท n). With 520 successes out of 1,000 at 95%: 0.52 ยฑ 1.96 ร 0.0158 = 0.489 to 0.551, or about 48.9% to 55.1%. For small samples or proportions near 0 or 1, the Wilson score interval is more accurate.
How can I make a confidence interval narrower?
Increase the sample size (quadrupling n halves the margin of error), reduce variability with better measurement, or accept a lower confidence level. A 90% interval is narrower than a 95% one, but it captures the true value less often.
What is the margin of error?
The margin of error is the ยฑ part of the interval: critical value ร standard error. A poll reporting 52% ยฑ 3.1 points at 95% confidence has a margin of error of 3.1 percentage points.