Confidence Interval Calculator

Enter a sample mean, standard deviation, and sample size to get a confidence interval — the calculator automatically switches from the normal (z) distribution to the t-distributionwhen your sample has fewer than 30 values, widening the interval to reflect the extra uncertainty. Switch to the proportion mode for survey-style percentages (with a built-in warning when the simple Wald formula produces an impossible bound below 0% or above 100%).

[93.808, 106.192]

95% confidence interval

n = 25 < 30 → t-distribution (df = 24), t* = 2.064

Show your work
Standard error = σ ÷ √n = 15 ÷ √25 = 15 ÷ 5 = 3
n = 25 < 30 → use the t-distribution, df = n − 1 = 24. Critical t for 95% confidence at df=24: t* = 2.064.
Margin of error = t* × SE = 2.064 × 3 = 6.192
95% CI = 100 ± 6.192 = [93.808, 106.192]

Automatically switches from the z to the t-distribution when n < 30. How we calculate →

Confidence interval for a mean: the formula

A confidence interval for a mean is x̄ ± z* · (σ ÷ √n) when your sample is large (n ≥ 30): the sample mean, plus or minus a margin of error built from the critical value (z*) and the standard error (σ ÷ √n). For a sample of 100 with mean 50 and standard deviation 10 at 95% confidence: standard error = 10 ÷ √100 = 1, margin of error = 1.960 × 1 = 1.96, giving a 95% CI of [48.04, 51.96].

The three standard confidence levels use fixed critical z-values: 90% → z* = 1.645, 95% → z* = 1.96, 99% → z* = 2.576. A higher confidence level always widens the interval — you trade precision for certainty.

Small samples (n < 30): why the calculator switches to the t-distribution

When the sample size is below 30, the normal (z) approximation understates how uncertain a small sample really is — the calculator switches to the t-distribution instead, which has fatter tails that widen the interval to reflect that extra uncertainty. The critical value then depends on the degrees of freedom (df = n − 1), not just the confidence level.

For a sample of 25 (df = 24) with mean 100 and sd 15 at 95% confidence, the critical value is t* = 2.064 (compare to z* = 1.96 for a large sample) — noticeably larger, which is exactly the point. Margin of error = 2.064 × 3 = 6.192, giving a 95% CI of [93.808, 106.192] — wider than the equivalent large-sample interval would be, even with the identical mean and sd.

As the sample size grows, the t-distribution converges toward the normal distribution — by df = 30, the critical t (2.042) is already close to the z-value (1.96).

Confidence interval for a proportion (Wald method)

For a proportion — like a survey's "62% said yes" — the formula is p̂ ± z* · √(p̂(1−p̂) ÷ n), known as the Wald interval. With 100 respondents and 50 successes (p̂ = 0.5) at 95% confidence: standard error = √(0.5 × 0.5 ÷ 100) = 0.05, margin of error = 1.96 × 0.05 = 0.098, giving a 95% CI of [0.402, 0.598].

The Wald method is simple but has a known weakness: with a small sample or a proportion near 0 or 1, it can produce an interval that extends past 0 or past 1 (impossible for a real proportion) — this calculator clips those cases and flags them explicitly. A sample of 10 with 9 successes (p̂ = 0.9) at 95% confidence produces exactly this: an upper bound over 1.0 that gets clipped. The Wilson score interval corrects for this weakness and is generally the better choice for small samples or extreme proportions — it isn't computed above, but the flag tells you when Wald's simpler formula has likely understated your true uncertainty.

How sample size changes your confidence interval

A bigger sample shrinks the margin of error, because standard error divides by √n — quadrupling your sample size only halves the margin of error, not divides it by four. Comparing the two mean examples above: the same standard deviation (roughly, allowing for the different means) but a sample of 100 versus 25 produces meaningfully different interval widths, both from the smaller √n and from switching to the wider t-distribution below n = 30.

Frequently asked questions

What is the formula for a confidence interval?

For a mean: x̄ ± z* · (σ ÷ √n) when n ≥ 30, or x̄ ± t* · (s ÷ √n) when n < 30 (t* from the t-distribution, df = n − 1). For a proportion: p̂ ± z* · √(p̂(1−p̂) ÷ n).

What z-value do I use for a 95% confidence interval?

z* = 1.96 for 95% confidence, z* = 1.645 for 90%, and z* = 2.576 for 99%. These apply when your sample size is 30 or more; below that, use the t-distribution instead.

When should I use the t-distribution instead of z?

Use the t-distribution whenever your sample size is below 30. It has fatter tails than the normal distribution, which widens your interval to account for the extra uncertainty of estimating from a small sample. A sample of 25 at 95% confidence uses t* = 2.064 (df = 24) instead of z* = 1.96.

How does sample size affect the confidence interval?

A larger sample narrows the interval, because the standard error divides by the square root of n — you need 4 times the sample size to cut the margin of error in half, not double it. Small samples (below 30) are also widened further by using the t-distribution instead of z.

What is a confidence interval for a proportion?

It estimates the range a true population proportion likely falls in, based on a sample proportion p̂. The simplest formula (Wald) is p̂ ± z* · √(p̂(1−p̂) ÷ n) — for example 0.5 ± 0.098 at 95% confidence with n = 100.

Why did my proportion confidence interval go above 100% or below 0%?

That's a known limitation of the simple Wald formula, which can produce impossible bounds with a small sample size or a proportion near 0 or 1. This calculator clips the bound to [0, 1] and flags it — the Wilson score interval avoids this problem entirely and is the better choice in that situation.

What's the difference between a 90%, 95%, and 99% confidence interval?

They use different critical values — z* = 1.645, 1.96, and 2.576 respectively — and produce progressively WIDER intervals for higher confidence. A 99% interval is more likely to contain the true value, but it's also less precise (a wider range) than a 90% interval from the same data.

Researched & verified by the Calcuris Data & Research Team. How we build and check our tools →