What Is Confidence Interval?
A confidence interval gives a range of plausible values for a population parameter. A 95 % interval means that if you repeated the sampling many times, about 95 % of the intervals built this way would contain the true value. It does not mean there is a 95 % chance that this particular interval contains it.
For a mean, the calculator uses a t interval when σ is unknown and a z interval when σ is known. For a proportion it offers the Wald, Wilson and Agresti-Coull intervals, because the simple Wald interval can perform poorly for small samples or extreme proportions. For a confidence interval for a population variance, use the sample variance calculator linked below.
Below you will find the formulas, a variables table, a worked example and answers to common questions such as how to find the 95 % confidence interval and how sample size affects the margin of error.
How to Use the Confidence Interval Calculator
- Choose whether you want an interval for a mean or a proportion.
- For a mean, enter raw data or summary statistics (mean, SD, n). For a proportion, enter the number of successes and the sample size.
- Pick a confidence level.
- Read the interval and margin of error. The chart compares methods; the table shows how the interval widens at higher confidence.
Confidence Interval Formula
Mean, σ unknown (t interval)
Mean, σ known (z interval)
Proportion, Wald
Proportion, Wilson
Confidence Interval Variables Explained
| Symbol | Meaning | Notes |
|---|---|---|
| x̄ | Sample mean | Centre of the interval |
| s or σ | Sample or population standard deviation | t interval or z interval |
| n | Sample size | |
| t*, z* | Critical value | Depends on confidence level |
| ME | Margin of error | Critical value × standard error |
| p̂ | Sample proportion | For proportion intervals |
Confidence Interval Worked Example
With the example values loaded in the calculator above, the steps are:
- n = 40, x̄ = 12.6, s = 1.8; standard error = s ÷ √n = 0.284605.
- t* (39 df) = 2.0227.
- Margin of error = 2.0227 × 0.284605 = 0.575668; CI = 12.6 ± 0.575668.
Result: 95% confidence interval for the mean = 12.0243 to 13.1757; Sample mean = 12.6; Margin of error = ± 0.575668.
How to Read the Interval
A sample of 40 with a mean of 12.6 and a standard deviation of 1.8 has a standard error of 1.8 ÷ √40 = 0.2846. The t critical value for 39 degrees of freedom is 2.0227, so the margin of error is 0.5757 and the 95% interval runs from 12.02 to 13.18.
The 95% describes the method, not this one interval: if you repeated the sampling many times, about 95% of the intervals built this way would contain the true mean. The width, 1.15 here, shrinks roughly in proportion to 1 ÷ √n, so quadrupling the sample to 160 would roughly halve it. A higher confidence level makes it wider.
How to interpret a confidence interval
The correct reading is about the procedure, not about this one interval: the method produces intervals that contain the true value in 95% of repeated samples. It is not correct to say there is a 95% probability that the true value lies in your particular interval, though that is a common and usually harmless shorthand.
Intervals are more informative than p-values alone. If a 95% interval for a difference excludes zero, the result is significant at the 5% level, and the interval also shows how large the effect might be.
| Confidence | z* | Alpha |
|---|---|---|
| 80% | 1.282 | 0.20 |
| 90% | 1.645 | 0.10 |
| 95% | 1.960 | 0.05 |
| 99% | 2.576 | 0.01 |
| 99.9% | 3.291 | 0.001 |
What controls the width of the interval
- Confidence level: higher confidence needs a wider interval.
- Sample size: the margin of error shrinks with 1/√n, so quadrupling n halves the width.
- Variability: more spread in the data means a wider interval.
- Method: for small samples the t interval is wider than a z interval to account for estimating s.
Which proportion interval should I use?
The Wald interval is taught first but performs poorly when the sample is small or the proportion is near 0 or 1: its real coverage can fall well below 95% and the limits can go outside 0 and 1. The Wilson interval fixes both problems and is the recommended default. The Agresti-Coull interval is a simple adjustment that gives similar results.
| Method | Small n | Extreme p | Comment |
|---|---|---|---|
| Wald | Poor | Poor | Simplest; use only for large n and p near 0.5 |
| Wilson | Good | Good | Recommended default |
| Agresti-Coull | Good | Good | Add z²/2 successes and failures, then use Wald |
Where Confidence Interval Is Used
Mean from data
Build a t interval for a mean from raw values or summary statistics.
Proportion
Get an interval for a proportion from successes and n.
Standard deviation
See an interval for the population SD as well.
Comparing methods
See how the choice of method changes the interval.
Common Confidence Interval Mistakes to Avoid
- Using z instead of t with a small sample and unknown σ.
- Using the population SD formula (n) rather than the sample SD (n − 1).
- Interpreting the interval as containing 95% of the data. It describes the mean, not individual values.
- Comparing two groups by checking whether their separate intervals overlap; use an interval for the difference instead.
- 95% is conventional but not magical; choose the level that suits the stakes.
- For small samples check normality or use a bootstrap interval.
- Report the interval with the estimate: 12.6 (95% CI 12.0 to 13.2).
Confidence Interval Terms and Definitions
- Margin of error
- Half the width of the interval: critical value times standard error.
- Confidence level
- The long-run proportion of such intervals that contain the true parameter.
- Coverage
- The actual proportion of intervals that capture the truth; may differ from the stated level.
Confidence Interval FAQs
What does a 95% confidence interval mean?
If you repeated the sampling many times and built an interval each time, about 95% of the intervals would contain the true population value.
When should I use t instead of z?
Use t whenever the population standard deviation is unknown and you estimate it from the sample, which is the usual situation. For large samples the two are nearly identical.
How do I make a confidence interval narrower?
Collect more data, accept a lower confidence level, or reduce variability. Quadrupling the sample size roughly halves the margin of error.
What is the margin of error?
It is half the interval width, equal to the critical value multiplied by the standard error.
Which interval should I use for a proportion?
The Wilson interval is recommended, especially for small samples or proportions near 0 or 1.
Can a confidence interval be used for hypothesis testing?
Yes. If the hypothesised value is outside the 95% interval, you reject it at the 5% level in a two-sided test.
Does a wider interval mean a worse study?
It means less precision. Wide intervals indicate more uncertainty about the true value.
When should I use a t interval and when a z interval?
Use t when the population standard deviation is unknown and you use the sample SD, which is the usual case. Use z only when sigma is known, or for a proportion. The t interval is wider for small samples.
Can I get a confidence interval from summary statistics only?
Yes. Choose summary statistics and enter the mean, standard deviation and sample size, or the count and sample size for a proportion.