How to use the confidence interval calculator
- Choose what the interval is for: one mean, a mean from your raw data, one proportion, or the difference between two groups.
- Enter the confidence level, usually 95%, and your sample’s numbers. For a proportion, give the number of successes or a percent such as 48%.
- The interval appears as you type, with the margin of error, the standard error, the critical value, a number line and each step.
What a confidence interval is
A sample mean or a poll result is a single best guess, but a different sample would give a slightly different number. A confidence interval shows how far off that guess could reasonably be. In the words of OpenStax’s Introductory Statistics, “A confidence interval is another type of estimate but, instead of being just one number, it is an interval of numbers.” It has the form point estimate ± margin of error.
For a sample of 25 with a mean of 7 and a standard deviation of 2.5, the 95% confidence interval is 5.96805 to 8.03195: the margin of error is ± 1.03195, and the sample mean sits in the middle.
What “95% confident” means
The confidence level describes the method, not one particular interval. If you repeated the study many times, drawing a new random sample and building a new interval each time, about 95% of those intervals would capture the true value. OpenStax puts it like this for a survey of smartphone owners: “Ninety-five percent of the confidence intervals constructed in this way would contain the true value for the population proportion”. It also reminds readers that “the confidence interval is a random variable. It is the population parameter that is fixed.”
A higher confidence level needs a wider interval: to be 99% sure of catching the true value, you have to cast a wider net than for 90%.
z or t: which critical value
The margin of error is a critical value times the standard error. “When the population standard deviation σ is known, we use a normal distribution to calculate the error bound,” and the critical value is z*. In practice the standard deviation almost always comes from the sample itself, and then the extra uncertainty is handled by Student’s t distribution with n − 1 degrees of freedom. The t value is larger than z for small samples, which widens the interval; “as the degrees of freedom increases, the graph of Student’s t-distribution becomes more like the graph of the standard normal distribution.” With σ treated as known, the same sample gives 6.02002 to 7.97998, a little narrower than the t interval.
| Level | z* | t* (10 df) | t* (30 df) |
|---|---|---|---|
| 80% | 1.282 | 1.372 | 1.31 |
| 90% | 1.645 | 1.812 | 1.697 |
| 95% | 1.96 | 2.228 | 2.042 |
| 98% | 2.326 | 2.764 | 2.457 |
| 99% | 2.576 | 3.169 | 2.75 |
| 99.9% | 3.291 | 4.587 | 3.646 |
Intervals for a proportion
For a proportion, such as the share of voters who back a candidate, the standard interval is p′ ± z* √(p′(1 − p′)/n). In OpenStax’s smartphone example, 421 of 500 adults owned one, and the 95% interval is 81.003% to 87.397%. The book adds a condition: “The confidence interval can be used only if the number of successes np′ and the number of failures nq′ are both greater than five.”
Two alternatives handle small samples better. The plus-four method adds two successes and two failures before using the same formula; for 6 smokers out of 25 students it gives 11.319% to 43.853%. The Wilson score interval shifts its centre toward 50% and never runs below 0% or above 100%, even when every answer in the sample is the same. The calculator lists all three so you can compare them.
Comparing two groups
To compare two means, the calculator builds an interval for the difference, x̄₁ − x̄₂, using a standard error that combines both samples and Welch’s t, which doesn’t assume the two groups have the same spread. “The degrees of freedom formula was developed by Aspin-Welch,” and it usually gives a fraction of a degree of freedom, which the calculator uses as it is. For workers averaging 5 years (s = 1.2, n = 15) at one company and 4 years (s = 1.5, n = 20) at another, the 95% interval for the difference is 0.0708144 to 1.92919. Because it doesn’t include 0, the data suggest a real difference. The same idea works for two proportions.
Working it out by hand
Here is the mean example from above, step by step, so you can check the calculator or follow along in class.
- Standard error: s / √n = 2.5 / √25 = 2.5 / 5 = 0.5.
- Critical value: the sample has 25 − 1 = 24 degrees of freedom, and the t value for 95% confidence is 2.0639.
- Margin of error: 2.0639 × 0.5 = 1.03195.
- Interval: 7 ± 1.03195, which is 5.96805 to 8.03195.
If you have the raw numbers rather than a summary, choose Mean from data. The calculator finds the mean and the sample standard deviation, dividing by n − 1, and then follows the same four steps.
Common mistakes
- Using z with a sample standard deviation. For small samples this makes the interval too narrow. Use t unless σ is genuinely known.
- Reading overlap as “no difference”. Two separate intervals can overlap even when the groups differ. In the workplace example, the single-group intervals are 4.33546 to 5.66454 and 3.29798 to 4.70202, which overlap, yet the interval for the difference, 0.0708144 to 1.92919, leaves out 0. Compare groups with an interval for the difference.
- Treating the interval as a range for individual values. It describes where the population mean or proportion is likely to be, not where most single measurements fall.
What makes an interval wider or narrower
- Sample size: the margin of error shrinks with √n, so four times the data roughly halves it.
- Spread: more variable data give a wider interval.
- Confidence level: 99% intervals are wider than 95%, which are wider than 90%.
A confidence interval only covers random sampling error. It can’t fix a biased sample, a leading survey question or measurement mistakes.
Your data stays on your device
Everything is worked out in your browser. Nothing you type is sent anywhere or stored.
Frequently asked questions
Should I use z or t?
Use t when the standard deviation comes from your sample, which is almost always. Use z only when you know the population standard deviation from outside the sample, or for proportions. With large samples the two give nearly the same answer.
What does 95% confidence mean?
If you took many random samples and built an interval from each one in the same way, about 95% of those intervals would contain the true population value. Any one interval either contains it or doesn’t; the 95% describes the method.
How do I make the interval narrower?
Take a bigger sample, or accept a lower confidence level. The margin of error shrinks with the square root of the sample size, so four times as many observations roughly halve it: with 100 values instead of 25 and the same mean and standard deviation, the 95% interval becomes 6.50395 to 7.49605.
Which proportion method should I pick?
The standard (Wald) interval is the one most textbooks teach and is fine when there are more than 5 successes and more than 5 failures. The Wilson score and plus-four intervals stay sensible for small samples and for proportions near 0% or 100%. The calculator shows all three side by side.
Can I paste data from a spreadsheet?
Yes. Choose Mean from data and paste a column or row of numbers. They can be separated by new lines, spaces, tabs, commas or semicolons, and up to 10,000 values are accepted.
Is anything I type saved or sent?
No. Everything is worked out in your browser and nothing you type is sent anywhere or stored.