CONFIDENCE INTERVAL CALCULATOR

Confidence interval calculator

Enter your sample's mean, SD and size, get the confidence interval.

How do I calculate a confidence interval?

Mean ± critical value × SD ÷ √n. For a sample of 30 with mean 100 and SD 15 at 95%: the t value is 2.045, the standard error 15 ÷ √30 = 2.739, so the interval is 100 ± 5.60 — from 94.40 to 105.60.

Should I use z or t?

Use t when the standard deviation comes from your sample — the usual case. Use z only when the population standard deviation is known. With large samples the two are nearly the same.

What does 95% confidence mean?

If you repeated the sampling many times, about 95% of the intervals built this way would contain the true mean. It does not mean a 95% chance for this one interval.

What are the common critical values?

For z: 1.645 at 90%, 1.960 at 95%, 2.576 at 99%. For t they are larger and depend on the sample size — 2.045 at 95% with 30 values.

How do I make the interval narrower?

Use a larger sample (the margin shrinks with √n) or accept a lower confidence level.

Is a 95% interval a range that holds 95% of the data?

No. A confidence interval is about the mean, not about individual values. With a sample SD of 15 the individual values spread far more widely than the interval for the mean, which is only ± 5.6 wide. A range for future single observations is a prediction interval, which is much wider and is not what this calculator computes.

How big a sample do I need for a given margin?

The margin is about critical value × SD ÷ √n, so to halve it you need four times the sample. In the example, going from 30 to 120 values at the same SD cuts the margin from ±5.60 to ±2.71. The sample size calculator solves the question the other way around, for proportions.

The formula and its assumptions

The interval is x̄ ± t* × s ÷ √n, where x̄ is the sample mean, s the sample standard deviation, n the number of values and t* the critical value from Student’s t distribution with n − 1 degrees of freedom for the chosen confidence level (NIST/SEMATECH e-Handbook of Statistical Methods, section 1.3.5.2). When the population standard deviation σ is known, z* from the normal distribution replaces t* and σ replaces s. The method assumes a random sample and a roughly normal population, or a large enough sample for the sample mean to be roughly normal.

Worked example: how confidence level changes the width

For a sample of 30 with mean 100 and SD 15 the standard error is 15 ÷ √30 = 2.739. At 90% the t value is 1.699, giving 95.35 to 104.65. At 95% it is 2.045, giving 94.40 to 105.60. At 99% it is 2.756, giving 92.45 to 107.55. More confidence costs width. If 15 were the known population SD instead, z would be 1.960 and the 95% interval 94.63 to 105.37, slightly narrower than with t.

Common mistakes

The first is entering the standard error where the standard deviation is expected, which shrinks the interval a second time by √n. The second is reading the 95% as the probability that this particular interval contains the mean: once computed, the interval either contains the true mean or it does not, and the 95% describes the long-run behavior of the method. Third, intervals for two groups that overlap do not by themselves prove the groups do not differ; a test on the difference is the correct tool. Finally, with a small n and skewed data the t interval can be unreliable, so look at the data first.

Sources: NIST/SEMATECH e-Handbook of Statistical Methods, section 1.3.5.2 (confidence limits for the mean); OpenStax Introductory Statistics 2e, chapter 8 (confidence intervals). Related: margin of error calculator, sample size calculator, critical value calculator and standard error calculator.