CALCULATOR

Confidence Interval Calculator

Build a confidence interval for a mean or a proportion, with margin of error, critical value and every step shown.

About this confidence interval calculator

A confidence interval gives a range of plausible values for an unknown population quantity, built from a sample. A 95% confidence interval for a mean, for example, comes from a procedure that captures the true mean in about 95 out of 100 repeated samples. This calculator builds the interval for a population mean from your sample mean, standard deviation and sample size, or for a proportion from the number of successes and the sample size. You get the lower and upper bounds, the margin of error, the critical value used and every step of the calculation.

The formulas

CaseInterval
Mean, sample SD (t)x̄ ± t* × s / √n, with df = n − 1
Mean, known population SD (z)x̄ ± z* × σ / √n
Proportion, Waldp̂ ± z* × √(p̂(1 − p̂) / n)
Proportion, Wilson(p̂ + z*²/2n ± z*√(p̂(1 − p̂)/n + z*²/4n²)) / (1 + z*²/n)

Common critical values

Confidencez*
90%1.645
95%1.960
98%2.326
99%2.576
99.9%3.291

Worked example

A sample of n = 25 has a mean of 52.4 and a sample SD of 8.1. With df = 24 and 95% confidence, t* ≈ 2.064. The standard error is 8.1 / 5 = 1.62, so the margin of error is 2.064 × 1.62 ≈ 3.34. The interval is 52.4 ± 3.34, or about 49.06 to 55.74.

How to read the result

Why Wilson for proportions

The simple Wald interval can fall outside 0 to 1 and covers poorly for small samples or proportions near 0 or 1. The Wilson interval stays inside the valid range and has better coverage, so it is the default here. Both are shown by choice.

Related tools: calculate your SD with the Standard Deviation Calculator, convert a statistic to significance with the P-Value Calculator, or standardize a value with the Z-Score Calculator.

Frequently asked questions

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

Compute the standard error, which is the sample SD divided by the square root of n. Multiply it by the critical t value for n minus 1 degrees of freedom (about 1.96 for large samples) to get the margin of error, then add and subtract that from the sample mean.

Should I use a t or z confidence interval?

Use t when the population standard deviation is unknown and you estimate it from the sample, which is the usual case. Use z only when the population SD is known. For large samples the two give nearly the same answer.

What does a 95% confidence level actually mean?

If you repeated the sampling and interval-building process many times, about 95% of the intervals would contain the true value. It does not mean there is a 95% chance the true value lies in this one interval.

What is the margin of error?

It is half the width of the interval: the critical value times the standard error. It describes how far the estimate is likely to be from the true value because of sampling variation.

How do I get a confidence interval for a proportion?

Divide successes by the sample size to get p-hat, then use the Wilson or Wald formula with the z critical value for your confidence level. This calculator does both and shows the lower and upper bounds as proportions and percentages.

How large a sample do I need for a narrow interval?

The margin of error shrinks in proportion to one over the square root of n. To halve the margin you need about four times as many observations. Use the margin of error shown here with different sample sizes to see the trade-off.