Skip to content

Confidence Interval Calculator

Type the mean, standard deviation and sample size, or paste your raw numbers, to get the confidence interval with Student’s t. Advanced adds proportions (Wald, Wilson and exact), two means, two proportions, one-sided bounds and small populations.

Proportions, two samples, one-sided bounds, population size
What do you have?
people or items
The standard deviation is
count
people
Group 1
Group 2
Method
Group 1
Group 2
Confidence level
%
Interval type

A one-sided bound puts all the leftover chance on one side, e.g. “at least …” with 95% confidence.

in total

Only matters when your sample is more than about 5% of everyone.

ResultUpdates as you type—Confidence interval—Estimate ± margin—Critical value—Standard error

How your confidence interval is worked out

Your numbers, step by step: the standard error, the t value for your confidence, the margin, then the range.

  1. 1

    Standard error

    10 ÷ √25 = 2

  2. 2

    Find t*

    95%, df 24 → 2.063899

  3. 3

    Margin of error

    2.063899 × 2 = 4.1278

  4. 4

    The range

    50.000 ± 4.128 = 45.872 to 54.128

Read more: the formula, a worked example, which method to pick, and what 95% really means

A confidence interval gives a range of likely values for something you can’t measure in full, such as the average height of every adult in a country, from a sample. It is the estimate from your sample plus and minus a margin of error. The margin grows with the spread of the data and the confidence you ask for, and shrinks as the sample gets bigger.

The formula

Mean (σ unknown): x̄ ± t* × s ÷ √n, with n − 1 degrees of freedom
Mean (σ known): x̄ ± z* × σ ÷ √n
Small population: multiply the standard error by √((N − n) ÷ (N − 1))
Proportion (Wald): p̂ ± z* × √(p̂(1 − p̂) ÷ n)
Proportion (Wilson): [p̂ + z²/(2n) ± z × √(p̂(1 − p̂)/n + z²/(4n²))] ÷ (1 + z²/n)
Proportion (Clopper–Pearson): from the beta distribution, Beta(α/2; x, n − x + 1) to Beta(1 − α/2; x + 1, n − x)
Two means (Welch): (x̄₁ − x̄₂) ± t* × √(s₁²/n₁ + s₂²/n₂), df = (s₁²/n₁ + s₂²/n₂)² ÷ [(s₁²/n₁)²/(n₁ − 1) + (s₂²/n₂)²/(n₂ − 1)]
Two proportions (Wald): (p̂₁ − p̂₂) ± z* × √(p̂₁(1 − p̂₁)/n₁ + p̂₂(1 − p̂₂)/n₂)

In words: the standard error is the standard deviation divided by the square root of the sample size. Multiply it by the critical value for your confidence level (t when the SD comes from your sample, z when it is known) to get the margin of error. The interval is the estimate minus the margin to the estimate plus the margin. For a two-sided 95% interval, t* leaves 2.5% in each tail; a one-sided 95% bound puts all 5% in one tail.

Worked example

A sample of 25 with a mean of 50 and a standard deviation of 10, at 95% confidence.

  • Standard error = 10 ÷ √25 = 10 ÷ 5 = 2.
  • Degrees of freedom = 25 − 1 = 24, so t* for 95% is 2.063899.
  • Margin of error = 2.063899 × 2 = 4.127797.
  • Interval = 50 − 4.127797 to 50 + 4.127797 = 45.872 to 54.128.
  • If σ = 10 were known, z* = 1.959964 and the margin would be 1.959964 × 2 = 3.919928, giving 46.08 to 53.92.

A proportion: 40 out of 100 at 95%. p̂ = 0.4 and z = 1.959964, so z² = 3.841459. Wald: √(0.4 × 0.6 ÷ 100) = 0.048990, × 1.959964 = 0.096018, giving 30.40% to 49.60%. Wilson: the centre is (0.4 + 3.841459 ÷ 200) ÷ (1 + 3.841459 ÷ 100) = 0.419207 ÷ 1.038415 = 0.403699 and the half-width is 1.959964 ÷ 1.038415 × √(0.0024 + 0.000096) = 0.094298, giving 30.94% to 49.80%. Clopper–Pearson gives 30.33% to 50.28%.

Two means (Welch): 75 (s 10, n 30) against 70 (s 12, n 25). s₁²/n₁ = 3.333333 and s₂²/n₂ = 5.76, so the standard error is √9.093333 = 3.015515 and df = 9.093333² ÷ (3.333333²/29 + 5.76²/24) = 46.83. t* = 2.011928, margin = 6.067, interval −1.07 to 11.07. It includes 0, so the difference is not significant at 95%.

What 95% confidence means (and doesn’t)

  • It is about the method. If you repeated the study many times and built an interval each time, about 95% of those intervals would catch the true value. The picture at the top of this page shows that: most bars cross the dashed line, and now and then one misses.
  • It is not a 95% chance for your one interval. Once you have your numbers, the true value is either inside or not. You just don’t know which.
  • It is not where 95% of the data are. That is a much wider range (roughly mean ± 2 SD). A confidence interval is about the average, not single values.
  • It only covers random error. A biased sample (only volunteers, only one city) gives a tight interval around the wrong answer.

Critical t values

df90%95%99%
52.01502.57064.0321
101.81252.22813.1693
201.72472.08602.8453
301.69732.04232.7500
601.67062.00032.6603
1201.65771.97992.6174
∞ (z)1.64491.96002.5758

Which method to pick

  • Mean: use t (the default). It assumes the data are roughly bell-shaped, or that the sample is big enough (about 30+) for the average to behave. For very skewed small samples, consider a bootstrap or a transformation.
  • Proportion: Wilson for everyday use; Clopper–Pearson when you must never under-cover (it is conservative); Wald only for large samples away from 0% and 100%, as a rough check.
  • Two means: Welch is the safe default because it doesn’t assume equal spreads. Pooled matches the classic Student’s t-test when the SDs are similar.
  • Two proportions: Newcombe’s score method (from two Wilson intervals) behaves better than Wald for small groups or extreme rates.
  • Paired data (before and after on the same people): work out each person’s difference first, then use “Mean (from raw data)” on those differences.

Critical values are computed from Student’s t distribution (incomplete beta function) and the normal distribution, and checked against published tables: t(0.975, 9) = 2.262157, t(0.975, 29) = 2.045230.

Common questions

How do I work out a confidence interval for a mean?

Divide the standard deviation by the square root of the sample size to get the standard error, multiply it by the t value for your confidence level (with n − 1 degrees of freedom), and add and take that margin from the mean. For a mean of 50, SD 10 and 25 people at 95%: 10 ÷ 5 = 2, t = 2.063899, margin = 4.128, so the interval is 45.87 to 54.13.

What does a 95% confidence interval really mean?

It means the method works 95% of the time: if you took many samples and built an interval from each, about 95 in 100 of them would contain the true value. It does not mean there is a 95% chance the true value is inside your particular interval, and it does not mean 95% of the data fall inside it.

Should I use t or z?

Use t when the standard deviation comes from your sample, which is nearly always. Use z only when the population standard deviation is truly known. For big samples the two are almost the same: at 95% t is 2.045 with 30 people and 1.984 with 100, against z = 1.960.

Which interval should I use for a proportion?

Wilson’s score interval is the best everyday choice: it stays inside 0–100% and works for small samples. Clopper–Pearson (exact) is the safest and a little wider. The simple Wald interval (p ± z√(p(1 − p)/n)) can be badly off when the sample is small or the proportion is near 0% or 100%.

What if a difference interval includes 0?

Then your data are consistent with no difference at that confidence level, which matches a two-sided test not being significant at the same level (for example 95% ↔ α = 0.05). If the whole interval is above or below 0, the difference is significant.

How do I make a confidence interval narrower?

Take a bigger sample (four times the sample halves the width), accept a lower confidence level, or reduce the spread by measuring more carefully. The width shrinks with √n, not n.

Related calculators

Sample size calculatorHow many people to survey for your confidence level and margin of error, the margin for a sample you have, means, response rates, design effect and A/B test sample sizes with power.Z-score calculatorZ-score from a value, value from a z-score, percentiles, the area under the bell curve (left, right, between, outside), p-values and a z-table.Standard deviation calculatorStandard deviation, variance, mean, median, mode, quartiles, outliers and confidence intervals from a list or a frequency table.Statistics calculatorEverything about a data set in one go: mean, median, mode, quartiles, outliers, SD, skewness, percentiles, z-scores, box plot and histogram, plus correlation and regression for two sets.

Made by Zulu Calculator, part of AlphaZulu LLC. Formulas are shown in full and rule figures are checked against official sources; see how we build calculators.

Embed this calculator on your site

Free to use on your website or blog. Paste this code where you want the calculator to appear. Please keep the credit link.

Confidence interval calculator by Zulu Calculator ↗