A confidence interval reports not just a single estimate but also its uncertainty: "the true value is probably in this range". The "margin of error ±3 points" in a survey is one form of confidence interval. Yet the phrase "95% confidence interval" is often misread. This guide first pins down its exact meaning, then computes intervals for a mean and for a proportion.
95% of what?
The population mean μ is unknown but fixed. A confidence interval, on the other hand, is a random interval that changes from sample to sample. The 95% therefore belongs to the method that builds the interval.
If you kept drawing samples the same way and building intervals, about 95% of those intervals would contain the true value.
Saying that a single computed interval, such as [45.74, 54.26], "has a 95% probability of containing μ" is strictly incorrect. That interval either contains μ or it does not; we just do not know which. In practice you say something like "at the 95% confidence level, the population mean is estimated to be between 45.74 and 54.26", which expresses the reliability of the method.
Two more common misreadings:
- "95% of the data lie in this interval": no. A confidence interval is about a parameter (such as the mean), and individual data spread much wider.
- "The next sample's mean will fall inside with 95% probability": also no. That is a question for a prediction interval.
The basic structure
Most confidence intervals share one shape:
estimate ± critical value × standard error
The critical value grows with the confidence level, and the standard error shrinks as the sample grows. Raising the confidence level widens the interval; enlarging the sample narrows it. The standard error is proportional to 1/√n, so halving the width requires four times the sample.
z or t?
For a confidence interval for a mean, the critical value depends on whether the population standard deviation σ is known.
- σ is known (rare): use the standard normal z. It is
1.96at 95%. - σ is unknown and replaced by the sample SD s (usual): use the t distribution with
n−1degrees of freedom.
The t value is larger than z because it reflects the extra uncertainty of estimating s, and the gap is larger for smaller samples.
| Degrees of freedom | 95% t critical value |
|---|---|
| 2 | about 4.303 |
| 5 | about 2.571 |
| 10 | about 2.228 |
| 15 | about 2.131 |
| 30 | about 2.042 |
| 100 | about 1.984 |
| infinity (z) | about 1.960 |
Example 1: Confidence interval for a mean
A sample of 16 has mean x̄ = 50 and sample standard deviation s = 8.
- Standard error:
SE = s / √n = 8 / √16 = 2 - Degrees of freedom:
16 − 1 = 15, 95% t critical value≈ 2.1314 - Margin of error:
2.1314 × 2 ≈ 4.263 - Interval:
50 ± 4.263→[45.74, 54.26]
Using z (1.96) instead gives 50 ± 3.92 → [46.08, 53.92], a narrower interval. Using z when σ is unknown makes the real coverage fall short of 95%, so small samples call for t.
Example 2: Confidence interval for a proportion (Wald and Wilson)
There are several formulas for a proportion p. The one taught first is the Wald interval.
- Wald:
p̂ ± z × √(p̂(1−p̂)/n)
If 120 of 400 people answer "yes", p̂ = 0.30.
- Standard error:
√(0.30 × 0.70 / 400) ≈ 0.02291 - Margin of error:
1.96 × 0.02291 ≈ 0.0449 - Wald 95% interval:
[0.2551, 0.3449]
The Wilson interval is derived by using the hypothesized value rather than p̂ inside the standard error. The formula is a little longer, but it behaves better.
- Wilson: center
(p̂ + z²/(2n)) / (1 + z²/n), half-widthz/(1 + z²/n) × √(p̂(1−p̂)/n + z²/(4n²))
For the same data it gives [0.2572, 0.3466], almost the same as Wald. When n is large and p̂ is far from 0 or 1, the two methods agree closely.
The difference shows up with small samples or proportions near the extremes. Take 2 out of 20 (p̂ = 0.10):
| Method | 95% interval |
|---|---|
| Wald | [−0.0315, 0.2315] |
| Wilson | [0.0279, 0.3010] |
The Wald lower bound is negative, which makes no sense for a proportion. Wald intervals are also known to have actual coverage well below the nominal 95% in such conditions. The Wilson interval stays within 0 to 1, its center is pulled slightly toward 0.5, and its coverage is closer to nominal. For these reasons Wilson is now often recommended as the default.
Confidence intervals and hypothesis tests
A 95% confidence interval for a mean and a two-sided t-test at the 0.05 level show the same information in different ways. If a value μ₀ lies outside the 95% interval, the two-sided p-value for the null hypothesis "the population mean is μ₀" is below 0.05. If it lies inside, the p-value is 0.05 or more.
The interval from Example 1, [45.74, 54.26], does not contain 45. A one-sample t-test against μ₀ = 45 indeed gives t = (50 − 45) / 2 = 2.5 and, with 15 degrees of freedom, a two-sided p ≈ 0.0245, below 0.05. The confidence interval adds the range of plausible values, so it carries more information than a single p-value.
Sample size matters too. With the same x̄ = 50 and s = 8 but 64 observations, the standard error is 8 / 8 = 1 and the t critical value at 63 degrees of freedom is about 1.998, so the interval is 50 ± 2.00 → [48.00, 52.00]. Quadrupling the sample cut the width from about 8.53 to 4.00, a bit more than half, because the t critical value also shrank.
Practical tips
- State the confidence level and the method, for example "95% CI (t distribution)" or "95% CI (Wilson)".
- Do not conclude "no difference" just because two intervals overlap. Compute an interval for the difference directly.
- Representativeness comes first. A confidence interval reflects only random sampling error, not response bias or selection bias.
This site's confidence interval calculator computes mean intervals (z and t) and proportion intervals (Wald and Wilson) side by side.
Key takeaways
- The 95% is the long-run coverage of the method, not the probability that μ lies in one computed interval.
- A confidence interval has the form
estimate ± critical value × standard error; halving its width takes four times the sample. - Use t when σ is unknown. For n = 16, x̄ = 50, s = 8, the 95% interval is
[45.74, 54.26]. - For 120 of 400, the 95% interval is
[0.2551, 0.3449](Wald) and[0.2572, 0.3466](Wilson). - With small samples or extreme proportions (such as 2 of 20) Wald can give a negative lower bound, so Wilson is recommended.