Confidence Interval Calculator

Choose a mean (with the population standard deviation, or the sample standard deviation) or a proportion. Enter your sample and a confidence level to get the lower and upper bounds.

Updated

Embed this calculator

Paste this code into your page. The calculator runs inside the frame and links back to the full version.

Keep the credit link in place. Do not resell the calculator.

Formula

  • Mean, σ known: mean ± z × σ / √n
  • Mean, σ unknown: mean ± t × s / √n, with n - 1 degrees of freedom
  • Proportion (Wilson score), with p = successes / n:
    • centre = (p + z²/(2n)) / (1 + z²/n)
    • half-width = z / (1 + z²/n) × √(p(1-p)/n + z²/(4n²))
    • interval = centre ± half-width, kept within 0 and 1

The critical value z (or t) is the 1 - (1 - level)/2 quantile: z = 1.645 (90%), 1.960 (95%), 2.576 (99%). A custom level accepts 50 to 99.999.

Worked example

Mean 50, s = 10, n = 25, 95% confidence, σ unknown:

  • Standard error = 10 / √25 = 2
  • t(24, 0.975) = 2.0639
  • Margin = 2.0639 × 2 = 4.1278
  • Interval = 45.8722 to 54.1278

With σ = 10 known, z = 1.96 gives a margin of 3.9199 and an interval of 46.0801 to 53.9199. For the Wilson interval, 20 of 100 at 95% gives 0.1334 to 0.2888.

Frequently asked questions

How do you calculate a confidence interval for a mean?

Use mean ± critical value × s / √n. With mean 50, s = 10, n = 25 and 95% confidence, t(24) = 2.0639, so the margin is 2.0639 × 10 / 5 = 4.1278 and the interval is 45.87 to 54.13.

When should I use z and when t?

Use z only when the population standard deviation σ is known. If you estimate it from the sample (the usual case) use t with n - 1 degrees of freedom. For the same data with σ = 10 known, the margin is 1.96 × 2 = 3.92 instead of 4.13.

What is the Wilson interval for a proportion?

The Wilson score interval is a more reliable alternative to p ± z√(p(1-p)/n), especially for small n or p near 0 or 1. For 20 successes in 100 at 95% it is 0.1334 to 0.2888, i.e. 13.3% to 28.9%.

What does 95% confidence really mean?

If you repeated the sampling many times and built an interval each time, about 95% of those intervals would contain the true value. It is not a 95% probability that this one interval does.

How does the confidence level change the width?

Higher confidence needs a larger critical value, so a wider interval. The z values are 1.645 for 90%, 1.960 for 95% and 2.576 for 99%, so going from 95% to 99% widens the interval by about 31%.