Confidence Interval Calculator
Compute a confidence interval for a population mean (using z or t) or a population proportion. Enter your sample statistics, pick a confidence level, and get the lower and upper bounds, the margin of error, and optionally the sample size needed for a target margin.
Formula
Worked example
Example (z-interval): mean = 100, sigma = 15, n = 30, 95% two-sided. SE = 15/sqrt(30) = 2.739; z* = 1.96; ME = 1.96 x 2.739 = 5.368; CI = [94.63, 105.37]. Example (proportion): p-hat = 0.42, n = 100, 95%. SE = sqrt(0.42 x 0.58 / 100) = 0.0494; ME = 1.96 x 0.0494 = 0.097; CI = [0.323, 0.517].
What a confidence interval tells you
A confidence interval is a range of plausible values for an unknown population parameter built from a single sample. Instead of reporting one number and pretending it is exact, you report a band that reflects sampling uncertainty. The interval is centered on your sample statistic and extends a margin of error in each direction. The width depends on three things: how spread out your data is (the standard deviation or proportion variability), how much data you collected (the sample size), and how much confidence you demand. Reporting the interval alongside the point estimate is standard practice in research because it communicates precision honestly.
z-interval vs. t-interval: choosing the right method
Use a z-interval when the population standard deviation is known. This is rare in practice, but it applies in quality-control settings with historical data, or when sample sizes are large enough that the sample SD is a reliable stand-in for the true population SD (roughly n = 30 or more). Use a t-interval when you are estimating the standard deviation from the sample itself. The t-distribution has heavier tails than the normal distribution, producing a slightly wider and more conservative interval. The exact width depends on the degrees of freedom (n minus 1): with small samples the difference is large; with n above 100 it becomes negligible. When in doubt, use the t-interval.
Confidence intervals for proportions
When your outcome is binary (yes/no, success/failure, click/no-click), use the proportion mode. The Wald interval used here centers the interval on the sample proportion p-hat and uses the standard error sqrt(p-hat x (1 - p-hat) / n). It works well when n x p-hat and n x (1 - p-hat) are both at least 5. If your proportion is very close to 0 or 1 or your sample is small, a Wilson score or Clopper-Pearson exact interval gives better coverage, but the Wald interval is accurate enough for most practical purposes with moderate samples.
One-sided confidence intervals
A two-sided interval reports both a lower and upper bound, which is the standard for most research. A one-sided interval is used when you only care about one direction: for example, a manufacturer who wants to guarantee that the true mean lifetime is at least a certain value would compute a one-sided lower bound. The one-sided bound is tighter than the two-sided bound for the same confidence level because all of the significance is placed in one tail rather than split across two.
How to find the required sample size
Toggle "Find required sample size" and enter a target margin of error. The calculator solves the margin formula in reverse: for a mean, n = ceil((z* x sigma / ME)^2); for a proportion with an estimated p-hat, n = ceil(z*^2 x p-hat x (1 - p-hat) / ME^2). If p-hat is unknown, use 0.5 as the most conservative assumption, which gives the largest possible required sample. Note that for a t-interval the critical value depends on df = n - 1, which itself depends on n, so the z-based formula is used as a close approximation for the reverse-solve.
Critical values for common confidence levels
| Confidence level | z* | t* (df=5) | t* (df=10) | t* (df=20) | t* (df=30) | t* (df=60) |
|---|---|---|---|---|---|---|
| 80% | 1.282 | 1.476 | 1.372 | 1.325 | 1.310 | 1.296 |
| 90% | 1.645 | 2.015 | 1.812 | 1.725 | 1.697 | 1.671 |
| 95% | 1.960 | 2.571 | 2.228 | 2.086 | 2.042 | 2.000 |
| 98% | 2.326 | 3.365 | 2.764 | 2.528 | 2.457 | 2.390 |
| 99% | 2.576 | 4.032 | 3.169 | 2.845 | 2.750 | 2.660 |
Two-sided critical values. t* is shown for selected degrees of freedom (df). For large df, t* converges to z*.
Frequently asked questions
What does a 95% confidence interval actually mean?
It means that if you drew many random samples and built an interval from each one using this method, about 95% of those intervals would contain the true population parameter. It does not mean there is a 95% probability that the true value falls inside this particular interval. The true value is fixed, and any single interval either contains it or does not.
When should I use a t-interval instead of a z-interval?
Use a t-interval whenever the population standard deviation is unknown and you are estimating it from the sample. In practice this covers the vast majority of real-world problems. The t-interval is always the safer choice: for large samples the t and z critical values are nearly identical, so you lose nothing by using t, and for small samples the t-interval gives correct coverage where z would be overconfident.
Why does a higher confidence level give a wider interval?
To be more confident that the interval captures the true parameter, you have to allow for a wider net. A higher confidence level uses a larger critical value, which multiplies the standard error into a bigger margin of error. Going from 95% to 99% raises z* from 1.96 to 2.576, widening the interval by about 31%. This is the fundamental trade-off between confidence and precision.
How many observations do I need for a given margin of error?
Toggle "Find required sample size" and enter your target margin. For a mean, the formula is n = ceil((z* x sigma / ME)^2), so quadrupling n halves the margin of error. For a proportion, n = ceil(z*^2 x p(1-p) / ME^2). If you do not know p in advance, use 0.5 as the worst-case assumption, which gives the largest (most conservative) required sample.
What is the difference between a one-sided and two-sided interval?
A two-sided interval provides both a lower and an upper bound and is the standard for most research and reporting. A one-sided interval sacrifices one bound to make the remaining bound tighter, which is appropriate when you only care about one direction, for example proving that a new drug is at least as effective as the control, or that a component lifetime is at least some minimum value.
Is the proportion confidence interval accurate for small samples?
The Wald interval used here (p-hat +/- z x SE) works well when both n x p-hat and n x (1 - p-hat) are at least 5. For proportions very close to 0 or 1, or for very small samples, the Wilson score interval or Clopper-Pearson exact interval provides better coverage. The rule of thumb: if your expected count of successes or failures is below 5, interpret the Wald interval with caution.