Skip to content
FigureSure
Sign in

Confidence Interval Calculator

Build a confidence interval for a population mean from your sample size, mean and standard deviation (t or z), or for a proportion with the Wilson score interval, with the Wald interval alongside for comparison.
  • Updated
  • Formula shown

What are you estimating?
Sample

Sample SD (s) for a t interval; population SD (σ) for a z interval

Between 80% and 99.9%

Results

95% confidence interval
69.5577 to 75.4423
x̄ ± t* × s/√n = 72.5 ± 2.9423
Margin of error
2.02269 × 1.45465
± 2.9423
Critical value (t*)
t distribution, 39 df
2.02269
Standard error
9.2 ÷ √40
1.45465

95% confidence interval: 69.5577 to 75.4423 (72.5 ± 2.9423)

The same sample at other confidence levels
Confidencet*MarginInterval
80%1.30364± 1.8963370.6037 to 74.3963
90%1.68488± 2.450970.0491 to 74.9509
95%2.02269± 2.942369.5577 to 75.4423
98%2.42584± 3.5287468.9713 to 76.0287
99%2.70791± 3.9390668.5609 to 76.4391
99.5%2.97561± 4.3284668.1715 to 76.8285
99.9%3.55812± 5.1758167.3242 to 77.6758

Uses Student’s t distribution with n − 1 = 39 degrees of freedom, because the SD is estimated from the sample.

How to use the confidence interval calculator

  1. Choose a mean with the standard deviation estimated from the sample (t), a mean with a known population SD (z), or a proportion.
  2. Enter the sample size and either the mean and SD, or the number of successes.
  3. Set the confidence level anywhere from 80% to 99.9%. A table shows the same data at other common levels.

Confidence interval formulas

Mean, σ unknown: x̄ ± t* × s ÷ √n, with n − 1 degrees of freedom
Mean, σ known: x̄ ± z* × σ ÷ √n
Wald (proportion): p̂ ± z* × √(p̂(1 − p̂) ÷ n)
Wilson score: [p̂ + z*² ÷ 2n ± z* √(p̂(1 − p̂) ÷ n + z*² ÷ 4n²)] ÷ (1 + z*² ÷ n)

x̄ is the sample mean, s the sample standard deviation, σ the population standard deviation, n the sample size and p̂ = x ÷ n the sample proportion. The critical value t* or z* cuts off (100% − confidence) ÷ 2 in each tail of the t or normal distribution. The product of the critical value and the standard error is the margin of error. The Wilson interval (Wilson, 1927) comes from inverting the score test; it is centered slightly towards 50% and never goes below 0 or above 1.

Worked examples

A mean. A sample of 40 delivery times has mean 72.5 minutes and standard deviation 9.2. The standard error is 9.2 ÷ √40 = 1.455. With 39 degrees of freedom the 95% critical value is t* = 2.023, so the margin of error is 2.023 × 1.455 = 2.942 and the 95% confidence interval is 69.56 to 75.44 minutes.

A proportion. In a survey, 27 of 40 people (p̂ = 0.675) prefer a new design. The 95% Wilson interval is 52% to 79.9%; the Wald interval is 53% to 82%. With no successes in 20 trials the difference is stark: Wald collapses to 0% to 0%, while Wilson gives a sensible 0% to 16.1%.

What "95% confidence" means

The confidence level describes the procedure. If you drew many samples and built an interval from each one, about 95% of those intervals would contain the true population value. Any single interval either contains it or does not; it is not correct to say there is a 95% probability that the true mean lies in this particular range. Higher confidence gives a wider interval; a larger sample gives a narrower one, in proportion to 1 ÷ √n.

z critical values by confidence level

Confidence levelz*
80%1.2816
85%1.4395
90%1.6449
95%1.9600
98%2.3263
99%2.5758
99.5%2.8070
99.9%3.2905

t critical values by degrees of freedom

Two-sided critical values t*, computed with this site's Student t engine. As the degrees of freedom grow, t* approaches the z* values above.

df90%95%99%
16.31412.70663.657
22.9204.3039.925
32.3533.1825.841
42.1322.7764.604
52.0152.5714.032
61.9432.4473.707
81.8602.3063.355
101.8122.2283.169
121.7822.1793.055
151.7532.1312.947
201.7252.0862.845
251.7082.0602.787
301.6972.0422.750
401.6842.0212.704
601.6712.0002.660
1201.6581.9802.617
∞ (z)1.6451.9602.576

Tips and common mistakes

  • Use t unless σ is truly known. If you calculated the SD from the same sample, the t interval is the right one; z understates the uncertainty for small samples.
  • Check the assumptions. The mean interval assumes independent observations and either a roughly normal population or a reasonably large sample (about 30 or more for moderate skew).
  • Prefer Wilson for proportions. The Wald interval needs at least about 10 successes and 10 failures; Wilson stays reliable well below that.
  • A confidence interval is not a range for individual values. It brackets the mean; to describe where individual observations fall, look at the standard deviation.

To plan how large a sample you need for a target margin of error, use the sample size calculator; to test a hypothesis instead, the p-value calculator works from your test statistic.

Frequently asked questions

How do you calculate a 95% confidence interval for a mean?

Use x̄ ± t* × s ÷ √n with n − 1 degrees of freedom. For n = 40, x̄ = 72.5 and s = 9.2, t* = 2.0227 and the standard error is 1.4546, so the margin is 2.94 and the interval runs from 69.56 to 75.44.

What does 95% confidence actually mean?

It describes the method, not one interval: if you repeated the sampling many times, about 95% of the intervals built this way would contain the true value. A single interval either contains it or not; it does not have a 95% chance of doing so after the fact.

Should I use t or z for a confidence interval?

Use t when the standard deviation is estimated from your sample, which is almost always. Use z only when the population SD is genuinely known. With 39 degrees of freedom t* = 2.023, slightly wider than z* = 1.960, to allow for the uncertainty in s.

Why use the Wilson interval for a proportion?

The simple Wald interval misbehaves with small samples or proportions near 0 or 1. With 0 successes out of 20, Wald gives 0% to 0%, which is clearly wrong, while the Wilson score interval gives 0% to 16.1%. For 27 out of 40 they are 52.0–79.9% (Wilson) and 53.0–82.0% (Wald).

How does sample size change the width of the interval?

The margin of error shrinks with the square root of n, so you need four times the sample to halve it. With a known SD of 10 at 95% confidence, n = 25 gives a margin of ±3.92 and n = 100 gives ±1.96.

Was this calculator helpful?