Confidence Interval Calculator
Enter a sample mean, its standard deviation and the sample size, or a count of successes out of n. Pick 90%, 95%, 99% or any other confidence level. The calculator returns the lower and upper bounds, the margin of error and the critical value it used. For a mean it uses t with n − 1 degrees of freedom when the standard deviation comes from your sample, and z when you know the population value. To work out how many responses you need before you collect them, use the sample size calculator instead.
The standard deviation comes from
Uses the t-distribution with n − 1 degrees of freedom.
How to use the Confidence Interval Calculator
- Choose Mean or Proportion, then a confidence level. Other level takes any value above 0 and below 100.
- For a mean, enter the sample mean, the standard deviation and n. Then say whether the standard deviation comes from the sample (t) or is a known population value (z).
- For a proportion, enter the number of successes and the sample size n.
- Press Calculate. The result shows the interval, both bounds, the margin of error and the critical value.
The confidence interval formulas
Mean: x̄ ± t* × s ÷ √n, with n − 1 degrees of freedom · · · Known σ: x̄ ± z* × σ ÷ √n · · · Proportion: p̂ ± z* × √(p̂(1 − p̂) ÷ n)
The critical value comes from the confidence level. z* leaves half of the remaining probability in each tail of the standard normal curve, so at 95% it cuts off 2.5% on each side: 1.645 at 90%, 1.96 at 95% and 2.576 at 99%. t* does the same on the t-distribution with n − 1 degrees of freedom. It is larger than z* for small samples and moves toward it as n grows. The calculator works out both from the level you enter, so it needs no table. The proportion interval is the normal approximation, also called the Wald interval. Beside it the calculator shows the Wilson score interval, which holds up better when there are only a few successes or failures.
Worked example
Ten measurements have a mean of 20 and a sample standard deviation of 4. At 95% confidence, t* with 9 degrees of freedom is 2.262157, so the margin of error is 2.262157 × 4 ÷ √10 = 2.8614 and the interval runs from 17.1386 to 22.8614. For a proportion, 50 yes answers out of 100 give p̂ = 50% and a margin of 1.96 × √(0.25 ÷ 100) = 9.8 percentage points, so the interval is 40.20% to 59.80%. The Wilson interval for the same answers is 40.38% to 59.62%.
Frequently asked questions
What does "95% confidence" mean exactly?
If you repeated the sampling many times, about 95% of the intervals you built would contain the true population value. It does not mean there is a 95% chance that the true value sits inside one particular interval.
Should I use t or z for a mean?
Use t when the standard deviation comes from the same sample, which is the usual case. Use z only when you know the population standard deviation from outside the sample. With 10 values at 95%, t* is 2.262157 and z* is 1.959964, so z would make the interval about 13% too narrow. With 1,000 values the two differ by less than 0.2%.
Why does a proportion get two intervals?
The Wald interval, p̂ ± z* × √(p̂(1 − p̂) ÷ n), is the textbook formula. It goes wrong near 0% and 100%. With 0 successes it has no width at all, and it can run below 0%. The Wilson score interval stays between 0% and 100%. For 2 successes out of 20 at 95%, Wald gives 0% to 23.15% after cutting off a lower bound of −3.15%, and Wilson gives 2.79% to 30.10%.
How does sample size affect the width of the interval?
The margin of error shrinks with the square root of n, so halving it takes about four times the data. To go the other way, from the margin you want to the n you need, use the sample size calculator. At 95% confidence it gives 385 for a 5% margin and 1,537 for a 2.5% margin.
What can I enter?
The standard deviation must be above 0. A t interval needs a sample size of at least 2, because it has n − 1 degrees of freedom. Sample sizes and successes are whole numbers, with successes from 0 up to n. Another confidence level must be above 0% and below 100%. Anything else gets a message instead of a result.