How to use this calculator
- 1 Enter the sample mean, which is the average of your sample.
- 2 Enter the sample standard deviation and the sample size, n.
- 3 Choose a confidence level, such as 95%.
- 4 Read the lower and upper limits. For samples under 30, the calculator uses a t interval and shows the z interval for comparison.
What is a confidence interval?
A confidence interval is a range of values built from a sample. It estimates a value you cannot measure directly, such as the average height of every adult in a country. The range is centred on your sample mean.
The confidence level, such as 95%, describes the method. If you took many random samples and built an interval from each, about 95% of those intervals would contain the true mean. Any single interval either contains it or does not.
A wider interval means more uncertainty. A higher confidence level makes the interval wider, because you want a better chance of catching the true value.
How the margin of error is found
The margin of error is the amount added and subtracted from the sample mean. It is the critical value times the standard error. The standard error is the sample standard deviation divided by the square root of n.
The critical value depends on the confidence level. For 95%, the z value is about 1.96. This is why the calculator shows the critical z in the working. As a result, a 99% interval uses a larger z and is wider than a 95% interval from the same data.
The square root of n means that more data makes the interval narrower, but only slowly. To cut the margin of error in half, you need about four times as many values.
| Confidence level | Critical z (two-sided) |
|---|---|
| 90% | 1.645 |
| 95% | 1.960 |
| 98% | 2.326 |
| 99% | 2.576 |
When to use a t interval
The z value assumes you know the true standard deviation of the population. In practice, you usually estimate it from the sample. When the sample is small, that estimate is less reliable, so the t distribution gives a wider, more honest interval.
For this reason, the calculator switches to a t interval when n is below 30. It uses n − 1 degrees of freedom for the critical value. For larger samples, the difference between t and z becomes small, so the z interval is a good estimate.
Either way, the method assumes random sampling. If the sample is biased, a narrow interval can still miss the true mean. A careful study design matters more than any formula.
Tips for using confidence intervals
Confidence intervals are easy to misread. Keep these points in mind when you report one:
- Describe the method, not the chance. Say “this method captures the true mean 95% of the time”, rather than “there is a 95% chance the mean is in this range”.
- Report the level. Always say which confidence level you used.
- Check the standard deviation. If you are unsure of it, the standard deviation calculator can compute it from your data.
- Plan the sample size first. If the margin is too wide, the sample size calculator shows how many values you need.
- Use the z-score for context. To see how far a single value is from the mean, try the z-score calculator.
The formula
Standard error
SE = s ÷ √n
- s
- the sample standard deviation
- n
- the sample size
Margin of error and interval
Margin = z × SE, Interval = x̄ ± z × SE
- x̄
- the sample mean
- z
- the critical z value for the confidence level, such as 1.96 for 95%
t interval (n below 30)
Interval = x̄ ± t × SE, with n − 1 degrees of freedom
- t
- the critical value from the t distribution
Worked example
Mean 50, standard deviation 12, sample size 100, 95% confidence
- 1.Standard error: 12 ÷ √100 = 1.2.
- 2.Margin of error: 1.959964 × 1.2 = 2.351957.
- 3.Interval: 50 ± 2.351957, from 47.648043 to 52.351957.
The 95% confidence interval for the mean is 47.648 to 52.352. With only 25 values, the t interval (45.0466 to 54.9534) is used instead.
Frequently asked questions
How do I calculate a confidence interval?
Divide the standard deviation by the square root of n to get the standard error. Multiply it by the critical value for your level, then add and subtract the result from the mean.
What does a 95% confidence interval mean?
It means the method captures the true mean in about 95% of repeated samples. It does not mean there is a 95% chance that this one interval contains the mean.
Why does a higher confidence level give a wider interval?
To be more sure of catching the true value, the interval must cover a wider range. A 99% interval uses a larger critical value than a 95% interval, so it is wider.
When should I use the t interval?
Use it when the sample is small, usually under 30, and you estimate the standard deviation from the same sample. The calculator switches to it automatically for those samples.
What sample size do I need for a narrow interval?
It depends on how much spread the data has and how narrow you want the margin. Because the margin shrinks with the square root of n, doubling your precision needs about four times as many values.
Sources
Last reviewed by the GridCalculators team.