gizmobench

Confidence Interval Calculator

Most confidence interval pages hand back two numbers and leave the choice of multiplier unexplained. This one shows the working: for a mean of 10, a sample standard deviation of 2 and n 25 at 95%, the standard error is 0.400000, the multiplier is t* 2.063899 on 24 degrees of freedom, the margin is 0.825559, and the interval is 9.17444 to 10.82556. Supply a known population standard deviation instead and the same sample switches to z* 1.959964 and narrows to 9.21601 to 10.78399, which is exactly what that choice is worth. Paste the raw numbers and the mean, the sample standard deviation and the count are worked out here instead.

Summary inputMean 10SD 2n 2595%
mean 10    sample SD 2    n 25    df 24

standard error   0.400000
t* (0.975, 24)   2.063899
margin           0.825559

95% CI    9.17444   to   10.82556

t was used because the SD is estimated from the sample
assumes independent observations from one population
Sample given as

You already have the mean, the standard deviation and the sample size. Type the three of them and the interval follows.

95% CI
9.17444 to 10.82556
Margin
0.825559
t* (df 24)
2.063899
Std. error
0.400000

95% is how often intervals built this way hold the population mean over repeated samples, not the chance that this one holds it: this interval either does or it does not. t was used because the SD is estimated from the sample. The third case below is the same sample down the other curve, so the cost of that choice is a number rather than an argument.

  • Mean 10, SD 2, n 25, 95%t, SD estimated
    9.17444 to 10.82556
  • The same sample at 99%t* 2.796940
    8.88122 to 11.11878
  • Population SD 2 knownz* 1.959964
    9.21601 to 10.78399
Accuracy. Exact arithmetic on your sample, using the t distribution when the standard deviation is estimated and z only when you supply a known population one, with the page naming which it used and on how many degrees of freedom. The interval is for the mean of the population the sample came from, assuming independent observations, and that assumption is printed beside it. It reports an interval and draws no conclusion about a treatment, a difference or an investment. The multipliers are computed rather than read off a four-figure table, and they were measured rather than assumed: against an 80-digit reference, the worst relative error was 2.72e-15 for t over 170,352 combinations of degrees of freedom and level, and 4.98e-16 for z. Whether your observations really are independent is a question about how they were collected, not about this arithmetic.

Common questions

How do I calculate a confidence interval for a mean?
Take the standard error, which is the standard deviation divided by the square root of the sample size, multiply it by the critical value for the level you want, and put that margin either side of the mean. For a mean of 10, a sample standard deviation of 2 and n 25 at 95%, the standard error is 0.400000, the multiplier is 2.063899 on 24 degrees of freedom, the margin is 0.825559, and the interval runs 9.17444 to 10.82556. Every one of those figures is printed on the page, so the arithmetic can be read rather than trusted.
Should I use t or z?
Use t whenever the standard deviation came from the sample itself, which is almost always. z belongs to the case where the population standard deviation is known ahead of the data, and it gives a narrower interval because it carries no uncertainty about the spread. This page uses t by default and switches to z only when you fill in a known population standard deviation, and it says on screen which one it used and why. For the same sample of 25 the two differ: 9.17444 to 10.82556 with t* 2.063899, against 9.21601 to 10.78399 with z* 1.959964.
Does a 95% confidence interval mean a 95% chance the true mean is inside it?
No, and that is the reading the number most often gets. The level describes the method over the long run: draw sample after sample, build an interval this way each time, and about 95 in 100 of those intervals would hold the population mean. The one on your screen either holds it or it does not, and nothing in the data says which. Raising the level widens the interval rather than sharpening the estimate: the same sample at 99% runs 8.88122 to 11.11878.
Can I paste my raw data instead of the summary?
Yes. Switch to Sample and paste the numbers separated by spaces, commas, semicolons or new lines, up to 100000 of them, and the mean, the sample standard deviation and the count are worked out here. The list 2, 4, 4, 4, 5, 5, 7, 9 has a mean of 5 and gives 3.21251 to 6.78749 at 95%, with a multiplier of 2.364624 on 7 degrees of freedom. The totals carry a compensation term as they accumulate, so a long sample of large numbers keeps its digits instead of drifting in the fifth decimal.
What is the smallest sample this works on?
Two observations. One has no spread to estimate and no degrees of freedom at all, so a sample size of 1 is refused with a message rather than answered. Two is enough for the arithmetic and not much else: at n 2 the multiplier for 95% is 12.706205, against 1.959964 if the standard deviation were known, and the interval that comes out is very wide. That width is the honest answer rather than a fault in the tool.
How accurate are the t and z multipliers?
They are computed rather than looked up from a four-figure table. z comes from Cody's rational Chebyshev approximation to the error function, inverted by Acklam's rational approximation and refined against the same curve. t comes from the incomplete beta function, evaluated as a continued fraction carried in two doubles and inverted by a bracketed Newton iteration. Both were measured against an 80-digit reference: t over 170,352 combinations of degrees of freedom and level, z over every level in that grid. The worst relative error found was 2.72e-15 for t and 4.98e-16 for z, so the bound quoted here is 1e-14, comfortably above what the measurement showed.

Exact arithmetic on your sample, using the t distribution when the standard deviation is estimated and z only when you supply a known population one, with the page naming which it used and on how many degrees of freedom. The interval is for the mean of the population the sample came from, assuming independent observations, and that assumption is printed beside it. It reports an interval and draws no conclusion about a treatment, a difference or an investment.