Skip to content

Confidence Interval Calculator

Get the confidence interval, margin of error and critical value for a sample mean (using z or t) or for a proportion using the Wilson score method.

Formulas last reviewed: September 2026

Disclaimer: Results are calculated with standard formulas and are meant for learning and quick checks. Please double-check important work, especially anything used for exams, engineering, finance or safety.

A range for the true value

A confidence interval gives a range that, at a chosen confidence level such as 95%, is expected to contain the true value for the whole population. It is written as the sample result plus or minus a margin of error.

This calculator builds the interval for a sample mean, using the normal (z) distribution when the population standard deviation is known and Student's t distribution when it is estimated from the sample, and for a proportion using the more reliable Wilson score interval.

How it is calculated

Mean: sample mean ± critical value × (s ÷ √n)
Margin of error = critical value × standard error

Worked example

Mean 50, SD 8, n = 40, 95% confidence

Standard error
1.2649
t critical value (39 df)
2.0227
Margin of error
2.56
Interval
47.44 to 52.56

What affects the width

  • A larger sample makes the interval narrower.
  • Higher confidence (99% instead of 95%) makes it wider.
  • More variable data (a larger standard deviation) makes it wider.

A 95% interval does not mean there is a 95% chance the true value is inside this one interval. It means 95% of intervals built this way would contain the true value.

Frequently asked questions

Should I use z or t?

Use t when the standard deviation comes from your sample, which is almost always. Use z only when the population standard deviation is genuinely known.

What confidence level should I pick?

95% is the usual choice. Use 99% when a wrong conclusion would be costly, accepting a wider range.

What is the Wilson interval?

It is a method for proportions that behaves well for small samples and for percentages near 0% or 100%, where the simple formula can fail.

How large a sample do I need?

Use the sample size calculator to plan the size for a target margin of error before you collect data.