1. Home
  2. Calculate
  3. Confidence Interval Calculator

Confidence Interval Calculator

Confidence intervals for means and proportions, margin of error and sample size.

Runs in your browser · No upload
Sample standard deviation s
95% confidence interval
45.8722 ~ 54.1278
50 ± 2.0639 × 10 ÷ √25 = 50 ± 4.1278
Margin of error (±)
4.1278
Standard error SE
2
Critical t (df 24)
2.063899
Lower bound
45.8722
Upper bound
54.1278

How to use

  1. Choose a calculation and a Confidence level (95% by default).
  2. Mean CI: enter the sample mean, standard deviation and sample size. Use t when you don’t know the population standard deviation (the usual case) and z when you do.
  3. Proportion CI: enter the number of successes x and the sample size n to get both the Wilson and Wald intervals.
  4. Sample size: enter the margin of error you want, and you’ll get the sample size you need, rounded up.

Formulas

Quantity Formula
Mean CI (t) x̄ ± t(α/2, n−1) × s ÷ √n
Mean CI (z) x̄ ± z(α/2) × σ ÷ √n
Proportion (Wald) p̂ ± z × √(p̂(1 − p̂) ÷ n)
Proportion (Wilson) (p̂ + z²/2n ± z√(p̂(1 − p̂)/n + z²/4n²)) ÷ (1 + z²/n)
Sample size (proportion) n = z² × p(1 − p) ÷ E²
Sample size (mean) n = (z × σ ÷ E)²
Finite population correction n = n₀ ÷ (1 + (n₀ − 1) ÷ N)

Common z values: 90% 1.6449, 95% 1.9600, 99% 2.5758. The t critical value depends on the degrees of freedom. Rather than looking it up in a table, the tool calculates it from the incomplete beta function (for example, df 24 at 95% → 2.0639).

Examples

  • Mean: 25 students average 50 points with a standard deviation of 10. The standard error is 10 ÷ √25 = 2 and t = 2.0639, so the 95% CI is 45.87 to 54.13 (margin ±4.13).
  • Proportion: 520 of 1,000 respondents say yes, so p̂ = 52%. The Wald margin is 1.96 × √(0.52 × 0.48 ÷ 1,000) = ±3.1 points. That’s the “margin of error of ±3.1 percentage points at 95% confidence” you often see quoted for 1,000-person polls.
  • Sample size: at 95% confidence, a ±5-point margin needs 385 respondents and ±3 points needs 1,068. If the whole population is only 1,000 people, ±5 points needs 278.

Things to keep in mind

  • A 95% CI doesn’t strictly mean “a 95% chance the true value is inside.” It means that if you repeated the sampling many times, about 95% of the intervals built this way would contain the true value.
  • With small samples, or proportions close to 0% or 100%, the Wald interval comes out too narrow or spills outside 0–100%. Use the Wilson interval in those cases.
  • The margin of error assumes a random sample. It doesn’t account for non-response, question wording or a biased sampling frame.

FAQ

When should I use t instead of z?

Use t whenever you estimate the standard deviation from the sample itself, which is nearly every real analysis. With samples in the hundreds, t and z are almost identical.

What expected proportion should I use for sample size?

Use 50%. p(1 − p) is largest at p = 0.5, so it gives the most conservative sample size, one that holds whatever the result turns out to be.

Where do I get the mean and standard deviation?

Paste your raw data into the average calculator to get the mean and the sample standard deviation s first.

Can't find the tool you need?

Tell us what you want to do. We build the most requested tools first.