The Quick Answer
A confidence interval is a range of values that likely contains the true population parameter. The formula for a mean is:
CI = x̄ ± t × (s / √n)
Where x̄ is the sample mean, t is the critical value, s is the sample standard deviation, and n is the sample size.
A 95% confidence interval means: if you repeated the sampling process many times, about 95% of the intervals you calculate would contain the true value.
You can compute confidence intervals instantly with the confidence interval calculator.
What Is a Confidence Interval?
When you measure something — average customer spend, poll results, test scores — you usually measure a sample, not the entire population. Your sample gives you a point estimate (a single number), but that estimate has uncertainty.
A confidence interval quantifies that uncertainty. Instead of saying "the average is 50," you say "we are 95% confident the true average is between 46 and 54." The interval gets wider when you have less data or more variability, and narrower when you have more data or less variability.
Three Components
Every confidence interval has three parts:
- Point estimate — Your best single guess (the sample mean or sample proportion)
- Margin of error — How far the interval extends above and below the point estimate
- Confidence level — How confident you are that the interval captures the true value (typically 90%, 95%, or 99%)
The Confidence Interval Formula for Means
When the population standard deviation is unknown (which is almost always the case), use the t-distribution:
CI = x̄ ± t × (s / √n)*
- x̄ = sample mean
- s = sample standard deviation
- n = sample size
- t* = critical value from the t-distribution (depends on confidence level and degrees of freedom, df = n − 1)
- s / √n = standard error (SE)
When the population standard deviation σ is known, or the sample size is large (n > 30), you can use the z-distribution instead:
CI = x̄ ± z × (σ / √n)*
Step-by-Step Example: CI for a Mean
A teacher wants to estimate the true average score on a math test. She samples 25 students and finds:
- Sample mean (x̄) = 78
- Sample standard deviation (s) = 12
- Sample size (n) = 25
- Confidence level = 95%
Step 1: Calculate the standard error
SE = s / √n = 12 / √25 = 12 / 5 = 2.4
Step 2: Find the critical value
Degrees of freedom = n − 1 = 24. For a 95% confidence level with df = 24, the t critical value is approximately 2.064.
Step 3: Calculate the margin of error
MOE = t* × SE = 2.064 × 2.4 = 4.95
Step 4: Build the interval
CI = 78 ± 4.95 = (73.05, 82.95)
Interpretation: We are 95% confident that the true average test score for all students falls between 73.05 and 82.95.
Try this example yourself with the confidence interval calculator — enter the mean, standard deviation, and sample size under "From Statistics" mode.
Second Example: Larger Sample
Same scenario, but the teacher samples 100 students instead of 25 (same mean and standard deviation).
- SE = 12 / √100 = 12 / 10 = 1.2
- t* for df = 99 at 95% ≈ 1.984
- MOE = 1.984 × 1.2 = 2.38
- CI = 78 ± 2.38 = (75.62, 80.38)
The interval is much narrower. Quadrupling the sample size roughly halved the margin of error. This is because standard error decreases by √n — doubling the sample size reduces the margin of error by about 29%, not 50%.
The Confidence Interval Formula for Proportions
When your data is a proportion (percentage of yes/no outcomes), the formula changes:
CI = p̂ ± z × √(p̂(1 − p̂) / n)*
- p̂ = sample proportion (successes / total)
- n = sample size
- z* = z critical value (1.645 for 90%, 1.960 for 95%, 2.576 for 99%)
Proportions always use the z-distribution, not the t-distribution.
Step-by-Step Example: CI for a Proportion
A survey asks 400 people if they prefer product A. Of those, 220 say yes.
- p̂ = 220 / 400 = 0.55 (55%)
- n = 400
- Confidence level = 95%, so z* = 1.96
Step 1: Calculate the standard error
SE = √(0.55 × 0.45 / 400) = √(0.2475 / 400) = √0.000619 = 0.0249
Step 2: Calculate the margin of error
MOE = 1.96 × 0.0249 = 0.0488 (about 4.9 percentage points)
Step 3: Build the interval
CI = 0.55 ± 0.049 = (50.1%, 59.9%)
Interpretation: We are 95% confident that the true proportion of people who prefer product A is between 50.1% and 59.9%.
Since the interval barely includes 50%, we can say with 95% confidence that a slight majority prefers product A — but the evidence is not overwhelming.
Confidence Levels: 90% vs. 95% vs. 99%
The confidence level controls how wide the interval is. Higher confidence means a wider interval.
Critical Values Reference
| Confidence Level | z* Value | When to Use |
|---|---|---|
| 90% | 1.645 | Exploratory analysis, quick estimates |
| 95% | 1.960 | Standard for most research and reporting |
| 99% | 2.576 | High-stakes decisions, regulatory reporting |
Same Data, Different Confidence Levels
Using the teacher's example (x̄ = 78, s = 12, n = 25):
| Level | Critical Value (t) | Margin of Error | Interval |
|---|---|---|---|
| 90% | 1.711 | ±4.11 | 73.89 to 82.11 |
| 95% | 2.064 | ±4.95 | 73.05 to 82.95 |
| 99% | 2.797 | ±6.71 | 71.29 to 84.71 |
There is always a trade-off: more confidence requires a wider interval. A 99% CI is not "better" than a 95% CI — it is simply more conservative.
What Affects the Width of a Confidence Interval?
Four factors determine how wide or narrow your interval is:
1. Sample Size (n)
More data → narrower interval. This is the most effective way to reduce uncertainty. The standard error is proportional to 1/√n, so you need to quadruple the sample size to cut the margin of error in half.
2. Variability (s or σ)
More spread in the data → wider interval. If individual values are all over the place, it is harder to pin down the true mean. You cannot control this directly, but you can reduce measurement noise through better methodology.
3. Confidence Level
Higher confidence → wider interval. Going from 95% to 99% increases the critical value from 1.96 to 2.576, widening the interval by about 31%.
4. Distribution Used (t vs. z)
Small samples → wider interval. The t-distribution has heavier tails than the normal distribution, especially for small sample sizes. With df = 5, the 95% t critical value is 2.571 (much larger than z = 1.96). As sample size grows, t approaches z.
The Most Common Mistake
The most widely misunderstood aspect of confidence intervals:
Wrong: "There is a 95% probability that the true mean is in this interval."
Right: "If we repeated this study many times, about 95% of the calculated intervals would contain the true mean."
The distinction matters because the true mean is a fixed (unknown) number, not a random variable. Once you calculate a specific interval, the true mean is either in it or it is not. The 95% refers to the long-run success rate of the method, not the probability for any single interval.
This is a subtle but important point. In practice, most people treat the interval as "the true value is probably in here" — which is a reasonable working interpretation, but it is not technically what frequentist confidence means.
When to Use t vs. z
| Situation | Use | Reason |
|---|---|---|
| Population σ known | z | No need to estimate variability |
| Population σ unknown, n ≥ 30 | z or t (both work) | t-distribution is close to normal for large n |
| Population σ unknown, n < 30 | t | t-distribution accounts for extra uncertainty |
| Proportion data | z | Proportions use the normal approximation |
In practice: use t for means (unless you know σ), use z for proportions. The confidence interval calculator handles this automatically.
Real-World Applications
Polling and Surveys
When a news report says "52% of voters support candidate X, with a margin of error of ±3 percentage points," that is a 95% confidence interval: 49% to 55%. The sample size and proportion determine the margin of error. Most political polls use sample sizes between 800 and 1,500 respondents.
A/B Testing
When testing two versions of a website, confidence intervals help decide if the difference in conversion rates is meaningful. If the confidence interval for the difference includes zero, the result is not statistically significant at that confidence level. You would need more data to draw a conclusion.
Quality Control
A factory measures the diameter of bolts from a production line. If the 99% confidence interval for the mean diameter falls within the tolerance range (e.g., 10.0 ± 0.1 mm), the batch passes inspection. This gives strong assurance that the manufacturing process is within spec.
Scientific Research
Most academic research reports 95% confidence intervals alongside p-values. The CI is often more informative because it shows both the direction and magnitude of an effect, not just whether it is "significant" or not.
Clinical Trials
Medical studies use confidence intervals to report treatment effects. For example: "The drug reduced blood pressure by 8 mmHg (95% CI: 5 to 11 mmHg)." This tells clinicians both the estimated effect and the range of plausible values.
Confidence Interval vs. Prediction Interval
These are often confused but answer different questions:
- Confidence interval: Where does the true average fall? (Narrower)
- Prediction interval: Where will the next individual observation fall? (Wider)
A prediction interval must account for both the uncertainty in the mean and the natural variability of individual data points, so it is always wider than the corresponding confidence interval.
Example
If the average commute time is 30 minutes (95% CI: 28 to 32), that is the confidence interval for the mean. A 95% prediction interval might be 15 to 45 minutes — any single commute could vary much more than the average.
Sample Size Planning
A common practical question: "How many samples do I need for a given margin of error?"
Rearranging the formula for a mean:
n = (z × s / MOE)²*
For a proportion:
n = (z / MOE)² × p̂(1 − p̂)*
Example
You want a 95% confidence interval for a proportion with a margin of error of ±3 percentage points. Assume p̂ = 0.5 (worst case, maximizes sample size).
n = (1.96 / 0.03)² × 0.5 × 0.5 = (65.33)² × 0.25 = 4268 × 0.25 = 1,068
You would need about 1,068 respondents. This is why most national polls survey around 1,000 people — it gives roughly ±3% margin of error at 95% confidence.
Common Mistakes to Avoid
Using z Instead of t for Small Samples
With fewer than 30 observations and an unknown population standard deviation, z critical values produce intervals that are too narrow. Use the t-distribution, which accounts for the extra uncertainty in estimating σ from a small sample.
Not Checking Assumptions
The CI formula for means assumes the data is approximately normally distributed (or the sample size is large enough for the Central Limit Theorem to apply, usually n ≥ 30). For the proportion formula, you need np̂ ≥ 5 and n(1 − p̂) ≥ 5. If these conditions are not met, the interval may not be reliable.
Confusing Confidence Level with Probability
As discussed above, the confidence level is a property of the procedure, not a probability statement about any specific interval.
Ignoring the Margin of Error
Reporting "the average is 50" without a confidence interval hides the uncertainty. An average of 50 with a margin of error of ±1 is very different from an average of 50 with a margin of error of ±20. Always report the interval.
Over-Interpreting Non-Overlapping Intervals
Two groups having non-overlapping confidence intervals does imply a statistically significant difference. But two groups with overlapping intervals do not necessarily mean the difference is insignificant. The correct approach is to compute a confidence interval for the difference between the groups.
Frequently Asked Questions
What is a confidence interval in simple terms?
A confidence interval is a range of values that is likely to contain the true value you are trying to estimate. It is calculated from sample data and accounts for sampling uncertainty. A wider interval means more uncertainty; a narrower interval means more precision.
What does "95% confidence" mean?
It means that if you repeated the sampling and calculation process many times, about 95 out of 100 intervals would contain the true population value. It does not mean there is a 95% probability that the true value is in any specific interval.
How do I calculate a 95% confidence interval?
For a sample mean: compute the standard error (SE = s / √n), find the t critical value for your degrees of freedom (df = n − 1) at the 95% level, then calculate x̄ ± t* × SE. For a proportion: use z = 1.96 and SE = √(p̂(1 − p̂) / n), then calculate p̂ ± 1.96 × SE.
What is the difference between confidence interval and margin of error?
The margin of error is half the width of the confidence interval. It equals the critical value times the standard error. The confidence interval is the point estimate plus or minus the margin of error.
When should I use a 99% confidence interval instead of 95%?
Use 99% when the consequences of being wrong are severe — for example, in safety-critical engineering, pharmaceutical testing, or regulatory compliance. The trade-off is a wider interval, meaning less precision. For general research and reporting, 95% is standard.
Can a confidence interval be negative?
Yes. If the point estimate is close to zero or the margin of error is large, the lower bound can be negative. For example, a confidence interval of (−2, 8) for a mean difference includes the possibility that the true difference is zero or negative. For proportions, the interval is typically clamped to [0, 1] since proportions cannot be negative.
What is a "narrow" vs. "wide" confidence interval?
A narrow interval indicates high precision — you have a good estimate of the true value. A wide interval indicates high uncertainty. The main way to narrow a confidence interval is to increase the sample size. Reducing variability in the data also helps, but is often harder to control.
How does sample size affect the confidence interval?
Larger samples produce narrower intervals. The standard error is proportional to 1/√n, so quadrupling the sample size cuts the margin of error in half. This is why researchers plan sample sizes in advance to achieve a desired level of precision.
What is the difference between a confidence interval and a p-value?
A p-value tells you the probability of observing your result (or something more extreme) if the null hypothesis is true. A confidence interval gives you a range of plausible values for the parameter. A 95% CI that does not include the null value corresponds to a p-value less than 0.05. The CI is generally more informative because it shows effect size and direction.
Can I use confidence intervals for non-normal data?
The formulas assume normality (or rely on the Central Limit Theorem for large samples). For non-normal data with small samples, consider bootstrap confidence intervals or non-parametric methods. For large samples (n ≥ 30), the CLT generally makes the normal-based CI reliable even if the underlying data is not perfectly normal.
What is a confidence interval for the difference between two means?
It estimates the range of plausible values for μ₁ − μ₂. The formula is: (x̄₁ − x̄₂) ± t* × √(s₁²/n₁ + s₂²/n₂). If the interval includes zero, the difference is not statistically significant at that confidence level.
How are confidence intervals used in medical research?
Clinical trials report treatment effects with confidence intervals. For example, "the drug reduced systolic blood pressure by 8 mmHg (95% CI: 5 to 11)." This tells clinicians the likely range of the true effect, which is more useful than just knowing whether the effect is "statistically significant."