What a confidence interval is and why you need one
A confidence interval is a range of numbers that likely contains the true value you are trying to measure. When you take a sample — say, measuring the height of 50 people from a city of 500,000 — you get one average. But that average is probably not exactly right. A confidence interval tells you how far off that average might be.
The interval has two bounds: a lower number and an upper number. When you say "I am 95% confident the true average is between 5.2 and 5.8," you are describing a confidence interval. The 95% is called the confidence level. It means that if you repeated your measurement many times, about 95 out of 100 times your interval would contain the true value.
You need a confidence interval whenever you measure something from a sample and want to know how much uncertainty is baked into that measurement. It is common in surveys, medical studies, quality control, and any field where you cannot measure everything.
Key Takeaways
- A confidence interval is a range with a lower and upper bound that likely contains the true value you are measuring.
- The most common confidence level is 95%, which means the true value falls within your range about 95 times out of 100 if you repeat the measurement.
- For a sample mean with a normal distribution, use the formula: sample mean ± (critical value × standard error).
- The standard error depends on the sample standard deviation and sample size; larger samples give narrower intervals.
- Use a t-distribution when your sample is small (under 30) or when you do not know the population standard deviation.
The formula for a confidence interval around a sample mean
The basic formula is: sample mean ± (critical value × standard error). This gives you the lower bound and upper bound of your interval.
The sample mean is the average of your measurements. The standard error is how much you expect that average to bounce around if you took many samples. The critical value is a number that depends on your confidence level and the shape of your data. Together, the critical value and standard error tell you how wide the interval should be.
The standard error is calculated as: standard deviation ÷ √(sample size). Notice that a larger sample size makes the standard error smaller, which makes your interval narrower and more precise. A sample of 100 gives you a tighter range than a sample of 10.
When to use the z-distribution versus the t-distribution
The critical value you use depends on whether your data follows a normal (bell-curve) distribution and how large your sample is. There are two common choices: the z-distribution and the t-distribution.
Use the z-distribution when your sample size is 30 or larger and you know the population standard deviation. In practice, you rarely know the population standard deviation, so this case is uncommon. For a 95% confidence level with the z-distribution, the critical value is 1.96.
Use the t-distribution when your sample size is under 30 or when you do not know the population standard deviation (which is almost always). The t-distribution is wider than the z-distribution, which means your interval will be slightly larger. The critical value depends on your sample size and confidence level. For a 95% confidence level with a sample of 25, the critical value is about 2.06. For a sample of 100, it is about 1.98 — closer to the z-value of 1.96.
Step-by-step calculation for a sample mean
Step 1: Calculate the sample mean. Add all your measurements and divide by the number of measurements. If you measured 10 people's heights in inches and got 66, 68, 70, 65, 72, 69, 71, 67, 70, 68, the mean is 686 ÷ 10 = 68.6 inches.
Step 2: Calculate the sample standard deviation. This measures how spread out your data is. Subtract the mean from each measurement, square the result, add all the squares, divide by (sample size − 1), and take the square root. For the height example, the standard deviation works out to about 1.96 inches.
Step 3: Calculate the standard error. Divide the standard deviation by the square root of the sample size. For the height example: 1.96 ÷ √10 = 1.96 ÷ 3.16 = 0.62 inches.
Step 4: Find the critical value. For a 95% confidence level with a sample of 10, use the t-distribution. The critical value is 2.26 (you can find this in a t-table or a statistics calculator).
Step 5: Multiply the critical value by the standard error. 2.26 × 0.62 = 1.40 inches. This is the margin of error.
Step 6: Add and subtract the margin of error from the sample mean. Lower bound: 68.6 − 1.40 = 67.2 inches. Upper bound: 68.6 + 1.40 = 70.0 inches. Your 95% confidence interval is 67.2 to 70.0 inches.
How sample size affects the width of your interval
A larger sample always gives you a narrower confidence interval, which means more precision. This is because the standard error shrinks as the square root of the sample size grows. If you double your sample size from 25 to 50, the standard error does not cut in half — it shrinks by a factor of √2, or about 1.41.
This matters when you are planning a study. If your interval is too wide to be useful, you need a bigger sample. If your interval is already narrow enough, collecting more data may not be worth the cost. The relationship is not linear, so there is a point of diminishing returns.
Confidence intervals for proportions and other statistics
The method above works for a sample mean. If you are measuring a proportion — such as the percentage of people who prefer one brand over another — the formula is slightly different. For a proportion, the standard error is: √[p(1−p) ÷ n], where p is the proportion and n is the sample size.
Other statistics like medians, correlation coefficients, and regression slopes also have their own formulas for confidence intervals. The principle is the same: you calculate a point estimate (the single number from your sample) and then add and subtract a margin of error based on the variability in your data and your desired confidence level.
If you are working with a statistic beyond the mean or proportion, a statistics textbook or software documentation will show you the correct formula. Most statistical software — including spreadsheet programs — can compute confidence intervals automatically once you enter your data.
Common confidence levels and their critical values
| Confidence Level | Z-Distribution Critical Value | T-Distribution Critical Value (n=25) |
|---|---|---|
| 90% | 1.645 | 1.71 |
| 95% | 1.96 | 2.06 |
| 99% | 2.576 | 2.80 |
The 95% confidence level is the standard in most fields. A 90% level gives you a narrower interval but less certainty. A 99% level gives you a wider interval but more certainty. The choice depends on how much risk you can tolerate. In medical research, 99% is common. In market research, 90% is sometimes used.
Frequently Asked Questions
Does a 95% confidence interval mean there is a 95% chance the true value is in my range?
Not exactly. Once you compute an interval, the true value either is or is not in that range — there is no probability. What 95% means is that if you repeated your measurement many times and computed an interval each time, about 95 out of 100 of those intervals would contain the true value. The confidence level describes the method, not the result.
What if my data is not normally distributed?
If your sample is large (over 30), the t-distribution still works well because of the central limit theorem — the distribution of sample means tends to be normal even if the original data is not. If your sample is small and your data is very skewed, you may need a different method, such as bootstrapping or a non-parametric approach. A statistics textbook or software documentation can guide you.
Can I use the same critical value for all my samples?
No. The critical value depends on your sample size and confidence level. A sample of 10 has a different critical value than a sample of 100, even at the same confidence level. Always check a t-table or use software to find the correct critical value for your specific sample size.
Why is my interval so wide?
A wide interval usually means your sample size is small or your data is very spread out (high standard deviation). Collect more data to narrow it. If you cannot collect more data, you can lower your confidence level from 95% to 90%, but this trades certainty for precision.
Should I round my confidence interval?
Round to a sensible number of decimal places — usually one more decimal place than your original measurements. If you measured height to the nearest inch, report your interval to one decimal place, such as 67.2 to 70.0 inches. Do not report false precision.