How it’s calculated
A confidence interval is a range built around a sample statistic. If you repeated the sampling many times, about the stated percentage of intervals built this way would contain the true value. The half-width is the margin of error (OpenStax calls it the error bound).
The critical values z and t come from the inverse normal and Student's t distributions (computed here from the regularized incomplete beta function, so any sample size works, not just table rows). Typical z values: 1.282 (80%), 1.645 (90%), 1.960 (95%), 2.326 (98%), 2.576 (99%). The t value is larger for small samples: t = 2.262 for 95% with 9 degrees of freedom.
For a proportion you can choose the Wilson score interval (the default, recommended by the NIST handbook) or the simple Wald interval taught in introductory courses. Wald is fine with plenty of data, but with fewer than 5 successes or failures it is unreliable, and with 0 or all successes it collapses to a single point, which is misleading. Wilson stays sensible there (for 0 of 20 at 95% it gives 0% to 16.1%). Both are cut off at 0% and 100%.
Example: a sample of n = 10 has mean 50 and s = 5. With 95% confidence and df = 9, t = 2.2622, so the margin of error = 2.2622 × 5 ÷ √10 = 3.577 and the interval is 46.42 to 53.58.
Frequently asked questions
When do I use z and when t?
Use z only when the true population standard deviation is known (rare in practice). When you estimate it from your sample with s, use t, which gives a slightly wider interval to account for that extra uncertainty. For large samples the two are nearly the same.
What does a 95% confidence interval mean?
It does not mean there is a 95% chance the true value is in this particular interval. It means the method captures the true value in 95% of repeated samples. A higher confidence level gives a wider interval.
How do I make the interval narrower?
Collect a larger sample (the margin shrinks with √n), accept a lower confidence level, or reduce variability in your measurements.
Does the t method need normal data?
The t interval assumes the population is roughly normal, but it is robust for moderate to large samples (about 30 or more). With very small samples and strongly skewed data, treat the result with caution.
Embed this calculator
Add this free calculator to your own website. Copy the code below into your page’s HTML:
Need this calculator branded, changed or built around your own prices?See custom business solutions →
Sources
- Introductory Statistics 2e, §8.1 A Single Population Mean using the Normal Distribution — OpenStax
- Introductory Statistics 2e, §8.2 A Single Population Mean using the Student t Distribution — OpenStax
- Introductory Statistics 2e, §8.3 A Population Proportion — OpenStax
- NIST/SEMATECH e-Handbook of Statistical Methods, 7.2.4.1 Confidence intervals for a proportion (Wilson method) — NIST
- NIST/SEMATECH e-Handbook of Statistical Methods, 1.3.6.7.2 Critical Values of the Student’s t Distribution — NIST
Formulas are taken from the free public references above. Results are provided “as is” for informational and educational purposes only. See our disclaimer.
Added · Last updated · How we check our calculators
Spotted a mistake or missing option? Report a problem· Suggest a calculator