Confidence Interval Calculator
Compute confidence intervals for a mean or a proportion (with steps). Choose Z or t, enter your sample stats, and get a clean interval visual.
Background
A confidence interval estimates an unknown population parameter (like a mean or proportion) using sample data. It has the form estimate ± critical × standard error. Higher confidence → wider interval.
How to use this calculator
- Choose what you’re estimating: Mean (Z), Mean (t), Proportion, or Sample size needed.
- Pick a confidence level (90/95/99% or custom).
- Enter your sample information (like x̄, n, σ, s, or x).
- Click Calculate to get the interval, margin of error, and optional steps.
How this calculator works
- Computes α from confidence: α = 1 − confidence, then uses α/2 for two-tailed intervals.
- Finds a critical value: z* for Z intervals, or t* with df = n − 1 for t intervals.
- Computes the standard error (SE) and margin of error: E = critical × SE.
- Outputs the final interval: estimate ± E (and clamps proportions to [0,1] for sanity).
- Shows optional assumption checks (e.g., normal approximation for proportions).
Formula & Equation Used
Mean (Z interval, σ known): x̄ ± z* · (σ/√n)
Mean (t interval, σ unknown): x̄ ± t* · (s/√n)
Proportion (Z interval): p̂ ± z* · √(p̂(1−p̂)/n)
Margin of error: E = critical · SE
Sample size (mean): n = (z*σ/E)²
Sample size (proportion): n = z*² · p(1−p) / E²
Example Problems & Step-by-Step Solutions
Example 1 — Mean (Z interval)
A sample has x̄ = 72.4, n = 25, and the population SD is known: σ = 10. Find a 95% CI for the true mean.
- For 95% confidence, z* ≈ 1.96.
- SE = σ/√n = 10/√25 = 2
- E = z*·SE = 1.96·2 = 3.92
- CI = 72.4 ± 3.92 → [68.48, 76.32]
Example 2 — Mean (t interval)
A sample has x̄ = 15.2, n = 12, and sample SD s = 3.1. Find a 95% CI for the true mean.
- df = n − 1 = 11. Use a t critical value t* for 95% confidence.
- SE = s/√n = 3.1/√12 ≈ 0.894
- E = t*·SE (the calculator computes t* and E automatically).
- CI = x̄ ± E
Example 3 — Proportion (Z interval)
Out of n = 120 students, x = 56 passed. Find a 95% CI for the true pass rate.
- p̂ = x/n = 56/120 ≈ 0.4667
- SE = √(p̂(1−p̂)/n)
- E = z*·SE with z* ≈ 1.96 for 95% confidence.
- CI = p̂ ± E (calculator outputs the final bounds).
Example 4 — Sample size needed (proportion)
You want a 95% CI with margin of error E = 0.03. If you don’t know p, use p = 0.5.
- For 95% confidence, z* ≈ 1.96.
- n = z*²·p(1−p)/E²
- Round up to the next whole number (calculator does this automatically).
Frequently Asked Questions
Q: Does a 95% confidence interval mean there’s a 95% chance the true value is inside?
Not exactly. The true parameter is fixed. The “95%” means that if you repeated the sampling method many times, about 95% of the intervals you build would contain the true value.
Q: When should I use Z vs t?
Use Z when the population SD σ is known (or for proportions). Use t when σ is unknown and you use the sample SD s. t intervals are especially common for small samples.
Q: What if my proportion sample is small?
The normal approximation can be weak when n·p̂ or n·(1−p̂) is small. In that case, a Wilson interval is often better (we can add it as an option).
Q: Why does higher confidence make the interval wider?
Higher confidence uses a larger critical value (z* or t*), which increases the margin of error E.
Q: What’s the difference between confidence level and margin of error?
Confidence level controls the critical value. Margin of error is the “±” width: E = critical × SE.