Calcylator
Confidence Interval

Confidence intervals:
a plain range around your sample mean

Work out an interval from a sample mean and standard deviation, pick between z and t, and avoid the usual misreadings.

Calcylator Editorial Team

Updated · 4 min read

A range instead of a single guess

A sample mean is one number drawn from one sample. A different sample would give a slightly different mean, so a single figure hides how much it could move. A confidence interval puts a range around the sample mean so the reader sees how precise the estimate is.

The usual choice of confidence level is 95 percent. It is a convention, not a law: 90 percent gives a narrower range, 99 percent a wider one, and the reader pays for extra certainty with extra width.

The formula when the population SD is known

Interval for a mean (σ known) =x̄ ± z × σ ÷ √n
x̄:
sample mean
z:
critical value for the chosen confidence level
σ:
population standard deviation
n:
sample size
σ ÷ √n is the standard error of the mean.
Confidence levelz critical value
90%1.645
95%1.960
99%2.576

The part after the plus-or-minus sign is the margin of error. It combines the confidence level, through z, and the precision of the sample, through the standard error. Add it to and subtract it from the mean and you have both ends of the range.

Notice what the formula leaves out. It does not know whether your sample was chosen fairly, only how much random variation to expect if it was. It also assumes the sample is small relative to the population; when you have measured a large share of a small population, a finite population correction narrows the interval.

Worked example with σ = 15

  • Sample mean

    100

  • Population SD

    15

  • Sample size

    100

  • Standard error

    15 ÷ √100 = 1.5

  • Margin of error

    1.96 × 1.5 = 2.94

95% confidence interval

97.06 to 102.94

Lower end 100 − 2.94, upper end 100 + 2.94.

A tidy way to read it: the sampling procedure produces intervals that capture the true mean about 95 percent of the time. For this one interval, the true mean is either inside it or not, and you do not know which.

Notice that the interval is symmetric around the sample mean and that a result of 98 or 102 would both be unremarkable against it. If the target value you care about, say a claimed average of 105, lies outside 97.06 to 102.94, the data are hard to square with that claim at this confidence level.

Using the t distribution when σ is unknown

Most real studies do not know σ. You estimate it from the sample SD, s, and that extra uncertainty is handled by replacing z with t, which depends on the degrees of freedom, n − 1. Small samples have heavier tails, so t is larger than z and the interval is wider.

Interval for a mean (σ unknown) =x̄ ± t × s ÷ √n
t:
critical value with n − 1 degrees of freedom
s:
sample standard deviation
  • Sample mean

    52

  • Sample SD

    8

  • n

    16, so 15 degrees of freedom

  • t (95%, 15 df)

    2.131

  • Standard error

    8 ÷ √16 = 2

95% confidence interval

47.74 to 56.26

Margin of error 2.131 × 2 = 4.262; the z value 1.96 would give a falsely narrow range.

As n grows, t approaches z. By about 30 observations the difference is small, and by 100 it is barely visible.

Software usually does this lookup for you, but it is worth knowing why the number changes. With only 5 observations the 95% t value is 2.776, more than 40 percent larger than 1.96, so a small study pays a real penalty in width. That penalty is the honest price of estimating spread from very little data.

What changes the width

Three levers control the margin of error, and only two of them are within your control.

  • Confidence level: moving from 95% to 99% multiplies the width by 2.576 ÷ 1.96, about 1.31.
  • Sample size: the width shrinks with the square root of n. Four times the data halves the margin.
  • Variability: a noisier population has a larger σ or s, and nothing you do after collecting data changes it.

To plan a study, flip the formula. For a margin of error of 1 unit with σ = 15 and 95% confidence you need n = (1.96 × 15 ÷ 1)² = 864.4, rounded up to 865. A calculator makes that kind of what-if test easy before any data is collected.

Intervals for proportions: polling and surveys

The same logic applies when the quantity is a share rather than a mean. For a sample proportion p̂ from n people, the standard error is the square root of p̂ × (1 − p̂) ÷ n, and the margin is z times that.

  • Sample

    1,000 respondents, 52% say yes

  • Standard error

    √(0.52 × 0.48 ÷ 1,000) = 0.0158

  • Margin of error

    1.96 × 0.0158 = 0.031

95% confidence interval

48.9% to 55.1%

The range crosses 50%, so the poll cannot say yes is ahead.

This is the origin of the familiar plus or minus 3 points. With p̂ at 50 percent, which is the widest case, a margin of 3 points needs about 1,068 respondents. Halving the margin to 1.5 points needs four times that, around 4,270. Headlines about a lead of two points in a poll of 1,000 are therefore often inside the noise.

What 95% does and does not mean

The common misreading is that there is a 95 percent chance the true mean lies within this particular interval. In the standard framework, the true mean is a fixed number and the interval is what varies from sample to sample. The 95 percent describes the long-run method.

Two intervals that overlap do not always mean the groups are the same, and two that just fail to overlap do not always prove a difference. For comparing groups, use a test or an interval built for the difference itself, not by eye.

It is worth being clear about what the interval is not. It does not account for question wording, who declined to answer, or measurement mistakes. It captures sampling variation only, which is why it is best read as the smallest uncertainty in the result, never the full picture.

Assumptions before you trust the result

  • Random or representative sampling. A biased sample gives a tight interval around the wrong value.
  • Roughly normal data or a reasonably large sample, so the mean behaves nicely.
  • Independent observations. Repeated measures on the same people need a different method.
  • Means only. Proportions, medians and ratios use their own formulas.

Common questions

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

Find the standard error, σ ÷ √n (or s ÷ √n), multiply by 1.96 for z (or the t value for n − 1 degrees of freedom), then add and subtract that margin from the mean. With σ = 15 and n = 100, the margin is 2.94.

What z value is used for a 95% confidence interval?

The two-sided critical value is 1.96, meaning 2.5 percent sits in each tail of the normal curve. The common values are 1.645 for 90 percent, 1.96 for 95 percent and 2.576 for 99 percent.

When should I use t instead of z?

Use t whenever the population standard deviation is unknown and you estimate it with the sample SD, which is nearly always. It matters most for samples under about 30. With 15 degrees of freedom, t is 2.131 against z's 1.96.

How does sample size affect a confidence interval?

Width is proportional to 1 ÷ √n. To halve the margin of error you need four times the observations. Going from 100 to 400 readings, for example, cuts a margin of 2.94 down to about 1.47.

Does a 95% confidence interval mean 95% of data falls inside it?

No. The interval describes where the mean of the population plausibly sits, not where individual values fall. Individual observations spread far wider, by roughly the standard deviation itself, so the interval is much narrower than the range of the data.

Was this guide helpful?

Continue reading

View all blogs