Confidence Interval Calculator (Mean and Proportion)
Choose a mean with the standard deviation from your sample (t), a mean with a known standard deviation (z), or a proportion. Enter your numbers and the confidence level to get the interval and its margin of error.
Last reviewed
95% confidence interval
94.3989 to 105.6011
100 ± 5.6011
- t critical (29 df)
- 2.0452
- Sample mean
- 100
- Standard error
- 2.738613
- Margin of error
- ±5.6011
This assumes a random sample from a roughly normal population, or a large enough sample. A 95% interval means the method captures the true mean in about 95% of repeated samples, not that this interval has a 95% chance.
What a confidence interval is
A sample gives you a single number, such as an average or a percentage, but the whole population would give a slightly different one. A confidence interval puts a range around your sample figure to show how much it could be off by chance alone. A 95% confidence interval comes from a method that, used on many random samples, would capture the true value about 95 times out of 100.
It is not the probability that the true value lies in this particular interval. Once the interval is worked out, the true value either is in it or is not. The 95% describes the method.
Interval for a mean
The interval is the sample mean plus and minus a margin of error:
x̄ ± critical value × (s ÷ √n)
where x̄ is the sample mean, s the standard deviation, n the sample size, and s ÷ √n the standard error.
When the population standard deviation is known (z). This is rare, but it happens when a measuring instrument has a known precision. A sample of 36 has a mean of 100, with a known σ of 15. At 95% the critical value is z = 1.96, so the margin is 1.96 × 15 ÷ 6 = 4.90, and the interval is 95.10 to 104.90.
When you use the sample’s own standard deviation (t). This is the usual case. The estimate of s is itself uncertain, so a slightly larger critical value from the Student t distribution is used, with n − 1 degrees of freedom. For the same figures with s = 15 and n = 36, the degrees of freedom are 35 and t = 2.0301, so the margin is 2.0301 × 15 ÷ 6 = 5.07 and the interval is 94.92 to 105.08. It is wider than the z interval, as it should be, since less is known.
Critical values
| Degrees of freedom | 90% | 95% | 99% |
|---|---|---|---|
| 1 | 6.314 | 12.706 | 63.657 |
| 2 | 2.920 | 4.303 | 9.925 |
| 3 | 2.353 | 3.182 | 5.841 |
| 4 | 2.132 | 2.776 | 4.604 |
| 5 | 2.015 | 2.571 | 4.032 |
| 10 | 1.812 | 2.228 | 3.169 |
| 20 | 1.725 | 2.086 | 2.845 |
| 30 | 1.697 | 2.042 | 2.750 |
| 60 | 1.671 | 2.000 | 2.660 |
| 100 | 1.660 | 1.984 | 2.626 |
| 1000 | 1.646 | 1.962 | 2.581 |
These are two-sided t values. As the degrees of freedom grow they approach the normal values, 1.645, 1.960 and 2.576, which are the z values used when σ is known. With a very small sample the penalty is large: with only 2 observations (1 degree of freedom), the 95% value is 12.706, not 1.96. The calculator works out the value for your exact sample size, up to 1,000 observations. Beyond that, use the “standard deviation known” option, with the sample’s s in place of σ; the difference is under 0.12%.
Interval for a proportion
For a yes/no result, such as 8 people out of 10 who liked a product, the sample proportion is p̂ = 0.8. The familiar textbook formula, p̂ ± z√(p̂(1 − p̂) ÷ n), is called the Wald interval, and it behaves badly. For 8 out of 10 it gives 55.21% to 104.79%, which is impossible. It also gives a width of zero when there are no successes at all.
The Wilson score interval fixes this. It is centred a little closer to 50% and never leaves 0% to 100%. For 8 out of 10 at 95% it gives 49.02% to 94.33%. For 0 out of 10, the Wilson interval is 0% to 27.75%: even with no successes in 10, a rate as high as 27.75% cannot be ruled out. For 50 out of 100 it is 40.38% to 59.62%, a margin of about ±9.6 points. The calculator shows the Wald interval beside it for comparison.
How big a sample do you need?
The margin of error shrinks with the square root of the sample size. To halve it, you need four times as many observations. To make a poll’s margin ±3 percentage points at 95%, you need about 1,068 people (n = z² × 0.25 ÷ 0.03², rounded up), and halving that to ±1.5 takes about 4,269. The z-score calculator explains the normal values behind these figures.
Common mistakes
- Reading 95% as a probability for this interval. It describes how often the method works.
- Using z when σ is estimated. With a small sample this makes the interval too narrow.
- Comparing overlapping intervals. Two 95% intervals can overlap and the difference between the groups can still be real. Test the difference directly.
- Using the Wald interval for small samples. It can reach below 0% or above 100%.
- Ignoring how the sample was chosen. The interval measures chance error only. A biased or self-selected sample is wrong at any size.
- Rounding the critical value. Using 2 instead of 1.96 gives a 95.45% interval, not 95%.
Related calculators
- Z-score calculator and statistics calculator.
- Average calculator and percentage calculator.
- Permutation and combination calculator and random number generator.
How it is calculated
The z critical value is the inverse of the normal distribution at (1 + level) ÷ 2. The t critical value solves the exact Student t formula for whole degrees of freedom, using its closed-form trigonometric sum and Newton’s method, in 60-digit decimal arithmetic. The mean interval is x̄ ± critical × s ÷ √n. The Wilson interval is (p̂ + z²/2n) ÷ (1 + z²/n) ± z ÷ (1 + z²/n) × √(p̂(1 − p̂)/n + z²/4n²), clipped to 0 to 1. Results are shown to four decimal places.
Frequently asked questions
What is a confidence interval?
A range, built from a sample, that is designed to capture the true value of a population figure such as a mean or a proportion. A 95% interval comes from a method that captures the true value in about 95 of every 100 random samples.
How do I calculate a confidence interval for a mean?
Take the sample mean and add and subtract the margin of error: t × s ÷ √n, where s is the sample standard deviation, n the sample size and t the critical value for n − 1 degrees of freedom. For mean 100, s = 15, n = 36 and 95%, t = 2.0301 and the margin is 5.07, so the interval is 94.92 to 105.08.
When should I use t and when z?
Use t when you estimate the standard deviation from your sample, which is almost always. Use z only when the population standard deviation is known in advance. With large samples the two give nearly the same answer, but t is always slightly wider.
Why does the proportion interval use the Wilson method?
The textbook (Wald) interval can fall outside 0% to 100% and covers poorly when the sample is small or the proportion is near 0 or 1. For 8 successes in 10 it gives 55.21% to 104.79%. The Wilson interval gives a sensible 49.02% to 94.33%. The Wald interval is shown for comparison.
What does the confidence level mean?
How often the method works, over many samples, not the probability for this one interval. Raising the level from 95% to 99% makes the interval wider, because catching the true value more often takes a wider net.
How do I make the interval narrower?
Take a bigger sample or accept a lower confidence level. The margin shrinks with the square root of the sample size, so to halve it you need four times as many observations.
Related calculators
- Z-Score CalculatorEnter a value, the mean and the standard deviation.
- Statistics CalculatorEnter your numbers, separated by commas, spaces or new lines.
- Average CalculatorPaste a list of numbers to get the average, with the sum, count, smallest and largest.
- Percentage CalculatorPick the question you are actually asking.
- Permutation and Combination CalculatorEnter n, the number of items to choose from, and r, how many you pick.
- Random Number GeneratorSet a minimum and maximum, how many numbers you want and whether repeats are allowed, then press Generate.
- Mean, Median, Mode and Range CalculatorEnter your numbers to see the mean, median, mode, range and midrange.
- Sample Size CalculatorChoose a confidence level and the margin of error you can accept.