A confidence interval is a range of plausible values for a population quantity, built as estimate ± critical value × standard error. For a sample of 16 measurements with a mean of 52.3 and a standard deviation of 8.0, the 95% confidence interval for the population mean is 52.3 ± 2.131 × (8.0 ÷ √16) = 52.3 ± 4.26, or 48.04 to 56.56.
The interval expresses uncertainty honestly. A single sample mean is almost never exactly equal to the population mean, and the interval shows how far off it plausibly could be.
The general recipe
Every confidence interval in introductory statistics has the same three parts:
- Estimate: the sample mean x̄ or sample proportion p̂.
- Standard error: how much that estimate typically varies from sample to sample.
- Critical value: how many standard errors to go out for the confidence level you want.
The product of the last two is the margin of error.
Confidence interval for a mean
When the standard deviation is estimated from the sample, which is the usual case, use the t-distribution with n − 1 degrees of freedom:
Worked example
A lab measures the tensile strength of 16 samples: mean x̄ = 52.3 MPa, standard deviation s = 8.0 MPa. Find a 95% confidence interval.
Standard error = 8.0 ÷ √16 = 8.0 ÷ 4 = 2.0
Degrees of freedom = 16 − 1 = 15 → t* = 2.131 for 95%
Margin of error = 2.131 × 2.0 = 4.26
Interval = 52.3 ± 4.26 = 48.04 to 56.56 MPa
The standard error calculator handles the first step, and the t-distribution calculator finds t* for any confidence level and sample size.
With a large sample
With n = 400 and the same mean and standard deviation, the standard error drops to 8.0 ÷ 20 = 0.4. With that many degrees of freedom, t* is essentially the normal value 1.96:
52.3 ± 1.96 × 0.4 = 52.3 ± 0.78 → 51.52 to 53.08 MPa
Twenty-five times more data made the interval about five and a half times narrower: a factor of 5 from √25, plus a little more because the critical value fell from 2.131 to 1.96.
Critical values
| Confidence level | z* (normal) | t*, df = 5 | t*, df = 10 | t*, df = 15 | t*, df = 30 |
|---|---|---|---|---|---|
| 90% | 1.645 | 2.015 | 1.812 | 1.753 | 1.697 |
| 95% | 1.960 | 2.571 | 2.228 | 2.131 | 2.042 |
| 99% | 2.576 | 4.032 | 3.169 | 2.947 | 2.750 |
The t values are larger than z for small samples, widening the interval to account for the extra uncertainty of estimating the standard deviation. As the degrees of freedom grow, t* approaches z*.
Confidence interval for a proportion
For survey results and other yes-or-no data, use the sample proportion p̂ and the normal distribution:
A survey of 1,000 adults finds 540 in favor: p̂ = 0.54
Standard error = √(0.54 × 0.46 ÷ 1,000) ≈ 0.0158
Margin of error = 1.96 × 0.0158 ≈ 0.031, or 3.1 percentage points
Interval = 50.9% to 57.1%
This simple interval (often called the Wald interval) works well when both n × p̂ and n × (1 − p̂) are at least about 10. For small samples or proportions near 0% or 100%, statisticians prefer adjusted methods such as the Wilson interval. The margin of error calculator and confidence interval calculator cover both means and proportions.
How to interpret the interval correctly
Correct: “We are 95% confident that the population mean is between 48.04 and 56.56 MPa,” meaning that the procedure produces intervals that capture the true mean 95% of the time.
Incorrect: “There is a 95% probability that the true mean is between 48.04 and 56.56.” Once the interval is calculated, the fixed true mean either is or is not inside it. The 95% belongs to the method, not to this one interval.
Also incorrect: “95% of the data falls in this interval.” A confidence interval describes where the mean is likely to be, not where individual measurements fall. Individual values spread far more widely.
A useful link to hypothesis testing: if a 95% interval for a difference excludes 0, a two-sided test of “no difference” would have a p-value below 0.05. See what is a p-value.
What controls the width
| Change | Effect on width |
|---|---|
| Larger sample size n | Narrower (width ∝ 1/√n) |
| Higher confidence level (95% → 99%) | Wider |
| More variable data (larger s) | Wider |
| Lower confidence level (95% → 90%) | Narrower |
Choosing a sample size
Turning the margin-of-error formula around tells you how many observations you need. For a proportion with margin of error E:
If you have no prior estimate of p, use 0.5, which gives the largest (safest) answer.
95% confidence, ±3 points: n = (1.96 ÷ 0.03)² × 0.25 ≈ 1,067.1 → 1,068 people
95% confidence, ±5 points: n = (1.96 ÷ 0.05)² × 0.25 ≈ 384.2 → 385 people
Always round up. This is why national polls so often survey around 1,000 to 1,500 people. The sample size calculator also handles means and finite populations.
Confidence intervals in a spreadsheet
Excel and Google Sheets return the margin of error directly. =CONFIDENCE.T(0.05,8,16) gives about 4.263 for the tensile-strength example (the first argument is 1 minus the confidence level), and =CONFIDENCE.NORM(0.05,8,400) gives 0.784 for the large-sample version. Add and subtract the result from the sample mean to get the interval. For proportions there is no built-in function, so compute the standard error with =SQRT(p*(1-p)/n) and multiply by =NORM.S.INV(0.975), which returns 1.96.
Assumptions to check
- Random sampling. No formula fixes a biased sample.
- Independence. Observations should not influence each other.
- Shape. For a mean with a small sample, the data should be roughly symmetric without strong outliers. With larger samples, the central limit theorem makes the mean approximately normal regardless.
The z-scores behind the critical values are explained in how to calculate a z-score, and the standard deviation input in how to calculate standard deviation by hand.
Frequently asked questions
What is the formula for a confidence interval?
Estimate ± critical value × standard error. For a mean with an estimated standard deviation, that is x̄ ± t* × s ÷ √n. For a proportion, it is p̂ ± z* × √(p̂(1 − p̂) ÷ n). The critical value depends on the confidence level, such as 1.96 for 95% with the normal distribution.
What does a 95% confidence interval mean?
It means the method used to build the interval captures the true population value in about 95% of samples. For any one interval, the true value is either inside it or not; the 95% describes how reliable the procedure is over many samples.
When should I use t instead of z?
Use the t-distribution for a mean whenever you estimate the standard deviation from the sample, which is almost always. The difference matters most for small samples; above roughly 30 to 50 observations, t and z critical values are close. Proportions use z.
How do I make a confidence interval narrower?
Increase the sample size, accept a lower confidence level, or reduce variability in the measurements. Because the width shrinks with the square root of n, you need four times as much data to cut the margin of error in half.
What is the difference between a confidence interval and a margin of error?
The margin of error is the half-width of the interval, the amount added to and subtracted from the estimate. A poll reporting 54% with a margin of error of 3.1 points has a confidence interval from about 50.9% to 57.1%.