Skip to content

Confidence Interval Calculator

Confidence intervals for a mean (z or t), a proportion (Wilson or Wald) or a difference of two means, with margin of error.

Your details

Interval for
Standard deviation

Results update as you type

Confidence interval

50 ± 4.1278 (45.8722 to 54.1278)

Lower bound
45.872203
Upper bound
54.127797
Margin of error (half-width)
4.127797
Point estimate
50
Standard error
2
Critical value (z* or t*)
2.0639
Degrees of freedom
24

Step-by-step solution
  1. SE = s / √n = 10 / √25 = 2
  2. t* (df = 24) = 2.0639
  3. E = t*·SE = 4.127797 ; 50 ± 4.1278

Same data at other confidence levels

A confidence interval turns a single sample estimate into a range of plausible values for the population parameter. Instead of saying "the average is 50", you say "the average is 50 ± 4.1 at 95 % confidence" — the estimate, plus an honest statement of how precise it is.

This calculator covers the three intervals met in almost every introductory course and in day-to-day analysis:

  • A mean, from the sample mean, standard deviation and size. Use Student's tt when the standard deviation was estimated from the sample (the usual case), or zz when the population σ\sigma is genuinely known.
  • A proportion, from a number of successes out of nn. The calculator defaults to the Wilson score interval, which keeps close to its nominal coverage even with small samples or proportions near 0 or 1, and shows the classic Wald interval next to it for comparison.
  • The difference between two means, from two independent samples, with Welch's unequal-variance method (default) or the pooled-variance method.

Pick a confidence level from 80 % to 99.9 %. You get the interval, its bounds, the margin of error, the standard error, the critical value $z^$ or $t^$, the degrees of freedom and a table of the same interval at other confidence levels.

How to use this calculator

  1. Choose what the interval is for: a mean, a proportion or two means.
  2. Select the confidence level — 95 % is the convention in most fields.
  3. Mean: enter xˉ\bar x, the standard deviation and nn; say whether the standard deviation comes from the sample (tt) or is a known population value (zz).
  4. Proportion: enter the number of successes xx and the sample size nn (for 81 "yes" out of 263, type 81 and 263). Keep Wilson unless a course asks for Wald.
  5. Two means: enter the mean, standard deviation and size of each sample; keep Welch unless you have a good reason to assume equal variances.
  6. Read the interval and margin of error; the steps show the standard error and the critical value used.

The formula

All three intervals have the form estimate ± critical value × standard error, with $z^* = \Phi^{-1}(1 - \alpha/2)$ and α=1−confidence\alpha = 1 - \text{confidence}.

Mean (NIST e-Handbook §1.3.5.2):

xˉ±z∗σn(σ known)xˉ±tn−1∗sn(σ unknown)\bar x \pm z^* \frac{\sigma}{\sqrt n} \quad (\sigma \text{ known}) \qquad \bar x \pm t^*_{n-1} \frac{s}{\sqrt n} \quad (\sigma \text{ unknown})

Proportion, with p^=x/n\hat p = x/n. Wald and Wilson score (Wilson 1927; Agresti & Coull 1998):

p^±z∗p^(1−p^)np^+z22n±zp^(1−p^)n+z24n21+z2n\hat p \pm z^* \sqrt{\frac{\hat p(1-\hat p)}{n}} \qquad \frac{\hat p + \frac{z^2}{2n} \pm z\sqrt{\frac{\hat p(1-\hat p)}{n} + \frac{z^2}{4n^2}}}{1 + \frac{z^2}{n}}

Difference of two means (Welch):

(xˉ1−xˉ2)±tν∗s12n1+s22n2ν=(s12n1+s22n2)2(s12/n1)2n1−1+(s22/n2)2n2−1(\bar x_1 - \bar x_2) \pm t^*_{\nu} \sqrt{\frac{s_1^2}{n_1} + \frac{s_2^2}{n_2}} \qquad \nu = \frac{\left(\frac{s_1^2}{n_1} + \frac{s_2^2}{n_2}\right)^2}{\frac{(s_1^2/n_1)^2}{n_1 - 1} + \frac{(s_2^2/n_2)^2}{n_2 - 1}}

The pooled version uses sp2=(n1−1)s12+(n2−1)s22n1+n2−2s_p^2 = \frac{(n_1-1)s_1^2 + (n_2-1)s_2^2}{n_1+n_2-2}, standard error sp1/n1+1/n2s_p\sqrt{1/n_1 + 1/n_2} and n1+n2−2n_1 + n_2 - 2 degrees of freedom.

Worked example

Mean, σ unknown. A sample of n=25n = 25 has xˉ=50\bar x = 50 and s=10s = 10. The standard error is 10/25=210/\sqrt{25} = 2, and with 24 degrees of freedom $t^* =$ 2.0639 at 95 %. The margin of error is 2×2 \times 2.0639 = 4.1278, so the interval runs from 45.872 to 54.128. If σ=10\sigma = 10 were known, $z^* = 1.96$ would give a slightly narrower margin of 3.9199.

Proportion. In a survey, 81 of 263 people answer yes: p^=\hat p = 0.308. The 95 % Wilson interval is 0.2553 to 0.3662; the Wald interval, 0.2522 to 0.3638, is shifted slightly towards 0. With 0 successes out of 20, Wald collapses to the useless interval 0 to 0, while Wilson gives 0 to 0.1611.

Two means. Group 1: xˉ1=72\bar x_1 = 72, s1=8s_1 = 8, n1=30n_1 = 30; group 2: xˉ2=68\bar x_2 = 68, s2=10s_2 = 10, n2=35n_2 = 35. The difference is 4 with standard error 2.234 and Welch degrees of freedom 62.73 ($t^* =$ 1.9985). The 95 % interval is 4 ± 4.46, from -0.46 to 8.46; it contains 0, so the data do not show a clear difference at this level.

What "95 % confidence" means — and what it does not

The 95 % describes the method, not one particular interval. If you repeated the study many times and built an interval each time, about 95 % of those intervals would contain the true mean or proportion. A single computed interval either contains it or not; you just don't know which.

It does not mean that 95 % of individual values fall in the interval — that is a prediction or tolerance interval, which is much wider. Nor does a wider interval mean a worse study: higher confidence always costs width. Going from 95 % to 99 % multiplies the margin by about 2.576/1.960≈1.312.576/1.960 \approx 1.31 for large samples.

To halve the margin of error you need four times as many observations, because the standard error shrinks with n\sqrt n. The sample size calculator works this out in reverse, from the margin you want.

Why Wilson instead of Wald for proportions

The Wald interval is the one most textbooks show first, but Brown, Cai and DasGupta (2001) and Agresti and Coull (1998) showed that its true coverage is often far below the nominal 95 %, even with hundreds of observations, and especially when p^\hat p is near 0 or 1. It can also produce impossible bounds below 0 or above 1, or a zero-width interval when there are no successes.

The Wilson score interval inverts the score test instead. It is never wider than needed, always stays within 0 and 1, and its coverage stays close to the nominal level. The rule "at least 10 successes and 10 failures" is a quick check for when Wald becomes acceptable.

Frequently asked questions

How do I calculate a 95 % confidence interval?

Compute the standard error (s/√n for a mean), multiply it by the critical value (1.96 for z, or t with n − 1 degrees of freedom), and add and subtract the result from the sample estimate. The calculator does all three steps and shows them.

What is the margin of error?

It is the half-width of the interval: critical value × standard error. A poll reported as "52 % ± 3 points" has a margin of error of 3 percentage points, usually at 95 % confidence.

Should I use z or t?

Use t whenever the standard deviation is estimated from the same sample, which is almost always the case. z is for a population σ that is truly known, and for proportions. With more than a few hundred observations the two give practically the same interval.

Why is the Wilson interval not centred on p̂?

Wilson pulls the centre slightly towards 0.5, by the amount z²/2n. This compensates for the skewed sampling distribution of a proportion near 0 or 1 and is the reason its coverage is better than Wald’s.

What if the interval for a difference contains 0?

Then a difference of zero is plausible at that confidence level, which matches a two-sided t-test that does not reject equality at α = 1 − confidence. If 0 lies outside, the test would reject.

Sources

Last updated:

More Statistics calculators

People also use