Skip to content
Statistics

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.

Your details

Use z when the population standard deviation is known; use t when you only have a sample standard deviation. Use Proportion for a fraction or percentage from a sample.
Enter any value between 1 and 99.99, such as 90, 95 or 99.
%
Two-sided is the standard choice. One-sided gives a lower or upper bound only.
The average of your sample (x-bar).
The known population standard deviation (sigma).
The number of observations in your sample (n). Must be at least 2 for t-intervals.
observations
Enter a target margin of error to calculate the minimum sample size needed.
Lower bound
94.6324
Upper bound105.3676
Margin of error5.3676
Standard error2.7386
Critical value1.96
Degrees of freedom-
Interval width10.7352
Required sample size-
Lower bound94.6324
Upper bound105.3676
Margin of error5.3676

We are 95% confident the true mean lies between 94.6324 and 105.3676.

  • The margin of error is +/-5.3676, so the interval spans 10.7352 units in total.
  • "95% confident" means that if you drew many random samples and built an interval each time, about 95% of those intervals would contain the true parameter. Any single interval either contains it or does not.
  • To shrink the margin of error, increase the sample size (it falls with the square root of n) or lower the confidence level.

Next stepToggle "Find required sample size" to see how many observations you need for a target margin of error.

Formula

Mean (z): xˉ±zσnMean (t): xˉ±tn1snProportion: p^±zp^(1p^)n\text{Mean (z): } \bar{x} \pm z^* \dfrac{\sigma}{\sqrt{n}} \quad \text{Mean (t): } \bar{x} \pm t^*_{n-1} \dfrac{s}{\sqrt{n}} \quad \text{Proportion: } \hat{p} \pm z^* \sqrt{\dfrac{\hat{p}(1-\hat{p})}{n}}

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 levelz*t* (df=5)t* (df=10)t* (df=20)t* (df=30)t* (df=60)
80%1.2821.4761.3721.3251.3101.296
90%1.6452.0151.8121.7251.6971.671
95%1.9602.5712.2282.0862.0422.000
98%2.3263.3652.7642.5282.4572.390
99%2.5764.0323.1692.8452.7502.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.

Sources

Written by Dr. Hannah Brandt, PhD Statistician · Munich, Germany

Applied statistician translating rigorous probability theory into clear, accurate tools for researchers and practitioners.

Search 3,500+ calculators

Loading search…