Confidence Interval Calculator

A confidence interval gives a range of plausible values for a population mean. With a sample mean of 50, standard deviation 10 and n = 25, the 95% confidence interval is 45.8722 to 54.1278, a margin of error of 4.1278 using the t-distribution.

Last updated · By · Runs in your browser, nothing is uploaded

Advanced options
%
Result

Step-by-Step Solution

Enter your values above to see the full working.

What Is a Confidence Interval?

A confidence interval is a range of values, built from sample data, that is likely to contain the true population value. Instead of reporting a single number such as “the average is 50”, you report “the average is 50, give or take about 4”. The interval is the honest version of an estimate because it shows how much uncertainty comes from sampling.

The confidence level describes the method, not any single interval. A 95% confidence level means that if you repeated the sampling process many times and built an interval each time, about 95% of those intervals would contain the true mean. It does not mean there is a 95% probability that this particular interval contains it.

What Affects the Width of the Interval

FactorChangeEffect on the interval
Sample size (n)LargerNarrower
Standard deviation (s)LargerWider
Confidence levelHigher (95% → 99%)Wider
Using t instead of zSmall samplesWider, which is more honest

Confidence Interval Formula for a Mean

CI = x̄ ± t* × (s ÷ √n)
  • x̄ is the sample mean, the centre of the interval.
  • s is the sample standard deviation.
  • n is the sample size.
  • s ÷ √n is the standard error, which measures how much the sample mean varies from sample to sample.
  • t* is the critical value from the t-distribution with n − 1 degrees of freedom, for your chosen confidence level.
  • t* × (s ÷ √n) is the margin of error.

When the population standard deviation σ is known, or the sample is very large, the z critical value (1.96 for 95%) can replace t*. This calculator uses t because the population standard deviation is rarely known, and it shows the z value for comparison. See the critical value calculator for other levels.

Worked Example: 95% Confidence Interval

A sample of 25 measurements has a mean of 50 and a standard deviation of 10.

  1. Standard error: 10 ÷ √25 = 10 ÷ 5 = 2.
  2. Degrees of freedom: 25 − 1 = 24.
  3. Critical value: for 95% confidence with 24 degrees of freedom, t* = 2.0639.
  4. Margin of error: 2.0639 × 2 = 4.1278.
  5. Interval: 50 − 4.1278 = 45.8722 and 50 + 4.1278 = 54.1278, so 45.8722 to 54.1278.

The Same Data at Different Confidence Levels

Confidence levelt* (df = 24)Margin of errorInterval
90%1.71093.421846.58 to 53.42
95%2.06394.127845.87 to 54.13
99%2.79695.593844.41 to 55.59

Greater confidence costs precision: the more certain you want to be, the wider the interval must be.

Confidence Interval for a Proportion

For yes-or-no data, the interval uses the sample proportion: p̂ ± z* × √[p̂(1 − p̂) ÷ n]. If 520 of 1,000 people support a measure, p̂ = 0.52 and the standard error is √(0.52 × 0.48 ÷ 1000) = 0.0158. At 95% confidence the margin of error is 1.96 × 0.0158 = 0.031, so the interval is about 48.9% to 55.1%. Notice that it includes 50%, so this poll cannot say that a majority definitely supports the measure.

How to Use This Confidence Interval Calculator

  1. Enter the sample mean.
  2. Enter the sample standard deviation. If you only have raw data, get it from the standard deviation calculator.
  3. Enter the sample size n (at least 2).
  4. Choose the confidence level, usually 95.
  5. Read the interval, margin of error, standard error and the t and z critical values. The steps show each substitution.

Real-World Uses of Confidence Intervals

  • Polling and surveys: a poll reports 52% support with a margin of error of ±3 points. That is a confidence interval.
  • Medicine: clinical trials report the effect of a treatment with a confidence interval so doctors can judge both size and certainty.
  • Business analytics: A/B tests use intervals to decide whether a conversion difference is real or noise.
  • Manufacturing: estimating the average strength or lifetime of a product from a limited test batch.
  • Planning a study: the sample size calculator works backwards from a desired margin of error.

How Sample Size Shrinks the Interval

With the same mean and standard deviation, raising n from 25 to 100 cuts the standard error from 2 to 1 and the 95% margin of error from 4.13 to about 1.98. Quadrupling the sample halves the standard error.

What Are the Most Common Mistakes With the Confidence Interval Calculator?

  • Misreading the confidence level. It is about the long-run success of the method, not the probability for one interval.
  • Confusing standard deviation with standard error. The interval uses s ÷ √n, not s itself.
  • Using z for a small sample. With small n and unknown σ, z understates the uncertainty. Use t.
  • Applying it to a biased sample. The interval only accounts for random sampling error, not poor sampling methods.
  • Ignoring the distribution. For very small, heavily skewed samples the t interval can be unreliable.
  • Overlapping-interval shortcuts. Two overlapping intervals do not automatically mean there is no significant difference. Use a proper two-sample t-test.

Where Can You Verify These Formulas?

The definitions and formulas on this page follow standard references. Check them against these sources:

Built and maintained by S. Dilshan. Found a mistake? Email [email protected] with the page address.

Frequently Asked Questions

What does a 95% confidence interval mean?

It means the method used to build the interval captures the true population mean in about 95% of repeated samples. It is not the probability that this particular interval contains the mean.

Should I use a t or z critical value?

Use t when the population standard deviation is unknown, which is almost always, especially for small samples. Use z when σ is known or the sample is very large. With large n the two give nearly the same answer.

How do I make a confidence interval narrower?

Increase the sample size, reduce variability in your measurements, or accept a lower confidence level. Increasing the sample size is usually the best option.

What is the margin of error?

It is half the width of the interval: the critical value multiplied by the standard error. In the example it is 4.1278, so the estimate is 50 ± 4.1278.

What sample size do I need?

It depends on how wide an interval you can tolerate and how variable the data is. Use the sample size calculator to work out n for a target margin of error.

Can a confidence interval include negative numbers?

Yes, if the sample mean is close to zero relative to its standard error, or if the quantity itself can be negative. Whether that is meaningful depends on what you are measuring.