Confidence Interval Calculator

Turn a sample mean into a range that likely contains the true population mean, with the margin of error and critical value shown.

The sample standard deviation s, or the population σ if it is known.

Result

95% confidence interval
93.80830432 to 106.1916957
  • Margin of error±6.191695685
  • Critical value t (df = 24)2.063899
  • Standard error (SD ÷ √n)3
  • Lower bound93.80830432
  • Upper bound106.1916957
  • Interval using z instead94.12010805 to 105.879892 (z = 1.96)
  • CI = x̄ ± t × s ÷ √n = 100 ± 2.063899 × 15 ÷ √25 = 100 ± 6.191695685
  • The t distribution is used because the standard deviation is estimated from a sample. It gives a slightly wider interval than z, especially for small samples.
  • Assumes a random sample from a roughly normal population, or a sample large enough for the central limit theorem to apply.

How to use the calculator

Enter the sample mean, the standard deviation, the sample size and the confidence level. The critical value setting decides which distribution to use:

  • Automatic uses t when n is below 30 and z from 30 up, matching the convention in many introductory courses.
  • Always t is the strictly correct choice when the standard deviation is estimated from the sample.
  • Always z is right when the population standard deviation is genuinely known.

The results show the interval, the margin of error, the critical value, the standard error and the interval you would get with the other method, so you can see how much the choice matters.

The formula

CI = x̄ ± critical value × s ÷ √n

The standard error s ÷ √n measures how much the sample mean varies from sample to sample. The critical value comes from the standard normal distribution (z) or from Student’s t distribution with n − 1 degrees of freedom (t), at the point that leaves (100% − confidence) ÷ 2 in each tail.

The calculator computes both critical values exactly, for any confidence level and any sample size, instead of looking them up in a short table. For example, it gives t = 2.262157 for 95% with 9 degrees of freedom, matching published t tables.

Worked example

The defaults are a sample of 25 measurements with a mean of 100 and a standard deviation of 15, at 95% confidence.

  1. Standard error: 15 ÷ √25 = 15 ÷ 5 = 3.
  2. Critical value: n is below 30, so t is used with 24 degrees of freedom: t = 2.063899.
  3. Margin of error: 2.063899 × 3 = 6.1917.
  4. Interval: 100 ± 6.19, or 93.81 to 106.19.

With z = 1.959964 instead, the margin would be 5.88 and the interval 94.12 to 105.88. The t interval is about 5% wider, which reflects the uncertainty of estimating the standard deviation from only 25 values.

Planning ahead

If the interval is wider than you need, work backwards. A margin of ±3 with the same spread would need roughly (1.96 × 15 ÷ 3)² ≈ 96 observations. For surveys that measure a percentage rather than an average, the margin of error works differently, because the spread comes from the proportion itself.

If you have raw data instead of a summary, find the mean and standard deviation first with the standard deviation calculator.

Limitations

  • The interval covers sampling error only. It cannot correct for a biased sample or measurement errors.
  • It assumes independent observations from a random sample.
  • It is an interval for the mean. It does not say where individual values fall, which is a much wider range.
  • With small samples from strongly skewed data, the actual coverage can fall short of the stated level.

Frequently asked questions

What does a 95% confidence interval mean?

If you repeated the sampling 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% chance that this one interval contains it. The true mean is fixed, and it is the interval that varies.

When should I use t instead of z?

Use t whenever the standard deviation comes from your sample, which is almost always. The t value is larger for small samples, which widens the interval to allow for the extra uncertainty. For large samples, t and z are nearly identical, which is why many courses switch to z at n = 30.

How can I make the interval narrower?

Collect more data, accept a lower confidence level, or reduce the variability of your measurements. Because the margin depends on 1 ÷ √n, halving it takes four times as many observations.

Does my data need to be normal?

For small samples, the data should be roughly normal without strong outliers. For larger samples, the central limit theorem makes the interval reliable for most distributions, though heavily skewed data may need more than 30 values.

Last reviewed: