Toolstia / Confidence interval calculator
Confidence interval calculator
A sample mean is only an estimate of the true average of the whole population. If you measured the heights of 25 people and found an average of 50, you would not claim the whole population is exactly 50. A confidence interval turns that single number into a range that reflects how much your sample is likely to vary.
Enter the sample mean, the standard deviation and the sample size, choose a confidence level of 80, 90, 95, 99 or 99.9 percent, and pick the t or the z distribution. The calculator returns the lower and upper bounds, the margin of error, and the critical value it used, with the degrees of freedom shown for t.
The t critical value is solved from the exact t distribution, not read from a rounded table, so it is available for any sample size from 2 upward. Everything is computed in your browser and nothing is uploaded.
Enter the mean, the standard deviation and a sample size of at least 2.
A 95% confidence interval means that if you repeated the study many times, about 95% of such intervals would contain the true mean. It does not mean a 95% chance for this one interval.
How it works
- Enter the sample mean, standard deviation and sample size.
- Choose the confidence level and the distribution.
- Read the interval, the margin of error and the critical value.
The formula
The interval is the mean ± margin of error. The margin of error is the critical value times the standard error, and the standard error is the standard deviation divided by the square root of n.
t or z
Use the t distribution when the standard deviation comes from your sample, which is the usual case. Use z only when the population standard deviation is known. For large samples the two give nearly the same answer.
Critical values
The t value is found for n − 1 degrees of freedom from the exact t distribution rather than from a rounded table, so any sample size and any confidence level works.
How to read it
A 95% interval means that if you repeated the sampling many times, about 95% of the intervals would contain the true mean. It is not the probability that this single interval does.
A worked example with real numbers
Suppose a sample of 25 gave a mean of 50 and a standard deviation of 8, and you want 95 percent confidence. The standard error is 8 divided by the square root of 25, which is 1.6. With 24 degrees of freedom the critical t value is 2.0639. The margin of error is 2.0639 times 1.6, which is 3.3022. The interval is 50 plus or minus 3.3022, from 46.698 to 53.302.
Switch to z and the critical value is 1.9600, the margin is 3.1359, and the interval is 46.864 to 53.136, slightly narrower. At 99 percent with t the critical value is 2.7969, the margin 4.4751 and the interval 45.525 to 54.475. The higher the confidence, the wider the range.
The method in steps
First the standard error is found: standard deviation divided by the square root of n. Next the critical value is found for the middle part of the distribution that matches your level. For 95 percent, the tool looks up the point with 97.5 percent of the distribution below it. For t this uses n minus 1 degrees of freedom; for z it uses the standard normal curve. The margin of error is critical value times standard error, and the interval is the mean minus and plus that margin.
The tool needs a sample size of at least 2 and a standard deviation of zero or more. A standard deviation of zero gives a zero-width interval, since there is no variation to measure.
t or z: which to choose
Use t when the standard deviation was calculated from your sample, which is nearly always. The t distribution has heavier tails, which allows for the extra uncertainty of estimating the spread from the same small sample. Use z only when the population standard deviation is genuinely known in advance, for example from a long-established process.
As the sample grows the two converge. With n equal to 25 the 95 percent critical values are 2.0639 and 1.9600. With n equal to 100 they are 1.9842 and 1.9600, so the margins are 1.5874 and 1.5680. With n equal to 2 the t value is 12.706, and the interval from a mean of 50 and a standard deviation of 8 runs from about -21.9 to 121.9, a true reflection of how little two measurements can tell you.
Which standard deviation to enter
Enter the sample standard deviation, the one computed with n minus 1 in the denominator. In a spreadsheet that is the STDEV.S function, not STDEV.P. Using the population version understates the spread slightly, and the effect is largest for small samples. If a paper reports a standard error instead, it is already the standard deviation divided by the square root of n, so multiply it by the square root of n to get the standard deviation to enter, or compute margin = critical value times that standard error directly.
Assumptions and what the interval does not say
The method assumes the observations are independent and come from a random sample, and that the population is roughly bell-shaped or the sample is large enough for the mean to behave normally. Strongly skewed data with a small sample can give an interval that is less reliable than its stated level. Biased sampling is not fixed by any amount of calculation.
A 95 percent interval does not mean 95 percent of the individual data values lie inside it. It describes the mean, not the spread of the data. Nor does it mean there is a 95 percent chance that this one interval holds the true mean. The 95 percent describes the method over many repeated samples. Also, two intervals that overlap do not always mean the groups are the same, so a proper comparison test is needed to decide that.
Reading and reporting the result
The page shows the range, both bounds with up to eight significant digits, the margin of error and the critical value with six. Report the interval with the level, for example: mean 50, 95 percent confidence interval 46.7 to 53.3, n = 25. Do not report more decimals than your data justifies.
To get a narrower interval, you need more data or less variable data. The width shrinks with the square root of the sample size, so halving the margin takes roughly four times as many observations. If you are planning a study and want to decide how large to make it, a sample size calculator is the right next step.
Questions
What makes the interval narrower?
A bigger sample, less variation in the data, or a lower confidence level.
Does it work for proportions?
No. This tool is for means. Use the sample size calculator for proportions.
Is anything uploaded?
No. Your numbers stays in your browser and is never sent anywhere.
Why is my interval so wide with a tiny sample?
With only a few observations the standard error is large and the t critical value is far above 2. With 2 observations at 95 percent it is 12.706. The interval is honest about how little the data can tell you.
Should I enter the standard deviation or the standard error?
Enter the sample standard deviation. The tool divides it by the square root of n itself. If you only have the standard error, multiply it by the square root of n first.
Does 95 percent mean 95 percent of values fall in the range?
No. The interval is for the mean, not for individual values. Most individual values will lie well outside it. A range for individual values would be a prediction interval.
Can the lower bound be negative?
Yes, the tool does not limit it. A negative lower bound for a quantity that cannot be negative, such as a length, usually means the sample is too small or too variable for a useful interval.