🎯 Confidence Interval Calculator
Confidence intervals for a mean or a proportion, the margin of error, and the sample size you need — with the critical value and every step.
Confidence interval formulas
- Mean (σ unknown): x̄ ± t* · s ÷ √n, with df = n − 1
- Mean (σ known): x̄ ± z* · σ ÷ √n
- Proportion: p̂ ± z* · √(p̂(1 − p̂) ÷ n)
- Margin of error is the part after ±: critical value × standard error.
Worked examples
Mean. 40 students sleep a mean of 6.8 hours with s = 1.2. SE = 1.2 ÷ √40 = 0.190; t* (95%, df 39) = 2.023; margin = 0.384. 95% CI: 6.42 to 7.18 hours.
Proportion. 312 of 500 surveyed students use the library weekly. p̂ = 0.624; SE = √(0.624 × 0.376 ÷ 500) = 0.0217; margin = 1.96 × 0.0217 = 0.042. 95% CI: 58.2% to 66.6%.
Sample size. For ±3 percentage points at 95%: n = 1.96² × 0.25 ÷ 0.03² = 1,067.1 → 1,068 people. For a mean within ±3 points when σ ≈ 15: n = (1.96 × 15 ÷ 3)² = 96.04 → 97.
The meaning of a confidence level is explained in the lesson Confidence intervals. To test a claim instead, use the t-test calculator.
Commands: Excel =CONFIDENCE.T(alpha, sd, n) and =CONFIDENCE.NORM return the margin of error; TI-84 STAT → TESTS → 8:TInterval, 7:ZInterval, A:1-PropZInt.
Questions and answers
What does “95% confident” mean?
If you repeated the sampling many times and built an interval each time, about 95% of those intervals would contain the true population value. It does not mean there is a 95% chance the true mean is in this one interval — the true mean is fixed; the interval is what varies.
When do I use t and when z?
For a mean, use t with n − 1 degrees of freedom when you only have the sample SD (almost always). Use z only if the population SD σ is known, which is rare outside textbook problems. For a proportion, use z.
How do I make the interval narrower?
Take a bigger sample (the margin of error shrinks with √n — four times the sample halves the margin) or use a lower confidence level. Lower variability in the data also helps.
What is the Wilson interval?
A better interval for a proportion when the sample is small or p̂ is close to 0 or 1. The usual (Wald) interval p̂ ± z·√(p̂(1 − p̂)/n) can go below 0 or above 1 and is too narrow in those cases; Wilson fixes this.
How large a sample do I need?
For a proportion with ±E margin at 95%: n = 1.96² × 0.25 ÷ E², so ±3 points needs 1,068 people and ±5 points needs 385. For a mean: n = (1.96 × σ ÷ E)². Use the “Sample size” tab.
What critical values go with common confidence levels?
z* = 1.645 for 90%, 1.960 for 95%, 2.576 for 99%. t* is larger for small samples: at 95% it is 2.262 with 9 df, 2.045 with 29 df and 1.984 with 100 df.