Mathematics · Probability & Statistics
Confidence Interval Calculator
Calculate the confidence interval for a population mean using sample data, standard deviation, and a chosen confidence level.
Calculator
Formula
Where x̄ is the sample mean, z* is the critical z-value for the chosen confidence level, σ is the population (or sample) standard deviation, and n is the sample size. The term z* · (σ / √n) is known as the margin of error.
Source: Montgomery, D.C. & Runger, G.C. — Applied Statistics and Probability for Engineers, 6th ed. (2014). Also consistent with NIST/SEMATECH e-Handbook of Statistical Methods, Section 7.2.
How it works
When we collect a sample from a population, we can compute a sample mean (x̄) as our best estimate of the true population mean (μ). However, different samples will produce slightly different means due to random variation. The confidence interval quantifies this uncertainty by building a range around x̄ that, under repeated sampling, would capture the true population mean a specified percentage of the time — typically 90%, 95%, or 99%.
The half-width of this interval is called the margin of error (E), calculated as E = z* · (σ / √n). The critical value z* is derived from the standard normal distribution and corresponds to the chosen confidence level: for a 95% confidence interval, z* = 1.96, meaning 95% of the standard normal distribution falls within ±1.96 standard deviations of the mean. The term σ / √n is the standard error of the mean — it represents how much the sample mean is expected to vary from sample to sample. As sample size n increases, the standard error decreases, producing a narrower and more precise interval.
The resulting interval [x̄ − E, x̄ + E] should be interpreted carefully: a 95% confidence interval does NOT mean there is a 95% probability the true mean lies in this specific interval. Rather, it means that if you were to repeat your sampling procedure many times and construct an interval each time, approximately 95% of those intervals would contain the true population mean. This frequentist interpretation is a cornerstone of classical statistical inference and is widely used in scientific research, quality control, polling, and clinical trials.
Worked example
Suppose a nutritionist measures the daily caloric intake of n = 50 adults and finds a sample mean of x̄ = 2,150 calories with a standard deviation of σ = 320 calories. She wants to construct a 95% confidence interval for the population mean daily caloric intake.
Step 1 — Identify the critical value: For a 95% confidence level, the critical z-value is z* = 1.96.
Step 2 — Calculate the standard error: SE = σ / √n = 320 / √50 = 320 / 7.0711 ≈ 45.25 calories.
Step 3 — Calculate the margin of error: E = z* × SE = 1.96 × 45.25 ≈ 88.7 calories.
Step 4 — Construct the interval: Lower bound = 2,150 − 88.7 = 2,061.3 calories. Upper bound = 2,150 + 88.7 = 2,238.7 calories.
Conclusion: The nutritionist can state with 95% confidence that the true average daily caloric intake in the population lies between approximately 2,061 and 2,239 calories. If a larger sample of n = 200 were used instead, the standard error would drop to about 22.6 and the margin of error to roughly 44.3 calories, demonstrating how increased sample size directly improves precision.
Limitations & notes
This calculator applies the z-interval formula, which assumes either a known population standard deviation or a large enough sample (generally n ≥ 30) for the Central Limit Theorem to ensure approximate normality of the sampling distribution. When the sample size is small (n < 30) and the population standard deviation is unknown, the t-interval (using Student's t-distribution with n − 1 degrees of freedom) is more appropriate and will produce wider, more conservative intervals. Additionally, this formula assumes simple random sampling from the population; if data were collected through stratified, cluster, or systematic sampling, different formulas are required. The calculator also assumes the underlying data do not contain severe outliers or extreme skew that would invalidate the normality assumption even for moderate sample sizes. Finally, a higher confidence level (e.g., 99%) always produces a wider interval than a lower one (e.g., 90%) for the same data, reflecting the trade-off between confidence and precision — a limitation that cannot be overcome without collecting more data.
Frequently asked questions
What does a 95% confidence interval actually mean?
A 95% confidence interval means that if you repeatedly drew samples from the same population and constructed an interval using the same method each time, approximately 95% of those intervals would contain the true population parameter. It does not mean there is a 95% probability that this specific interval contains the true mean — once the interval is calculated, the true mean either is or isn't inside it. This distinction is subtle but important in formal statistical reasoning.
When should I use a t-interval instead of a z-interval?
You should use a t-interval when your sample size is small (typically n < 30) and you are estimating the population standard deviation from the sample itself. The t-distribution has heavier tails than the normal distribution, which accounts for the additional uncertainty introduced by estimating σ from limited data. As sample size grows, the t-distribution converges to the standard normal distribution, so for large samples the z-interval and t-interval produce nearly identical results.
How does increasing sample size affect the confidence interval?
Increasing the sample size n directly reduces the standard error (σ / √n), which in turn decreases the margin of error and produces a narrower confidence interval. For example, quadrupling the sample size cuts the margin of error in half. This is why studies with larger samples are considered more precise — they provide tighter bounds on the population parameter without sacrificing confidence level.
What is the difference between standard deviation and standard error?
Standard deviation (σ or s) measures the variability of individual observations within a dataset — it describes how spread out the data points are around their mean. Standard error (SE = σ / √n) measures the variability of the sample mean itself across repeated samples — it describes how much the sample mean is expected to differ from the true population mean. The standard error is always smaller than the standard deviation (for n > 1), and it is the standard error, not the standard deviation, that determines the width of a confidence interval.
Can I use this calculator for proportions or other statistics?
This calculator is specifically designed for estimating a population mean using the z-interval formula. Confidence intervals for proportions use a different formula: p̂ ± z* · √(p̂(1−p̂)/n), where p̂ is the sample proportion. Similarly, intervals for variances, regression coefficients, and differences between means require their own dedicated formulas and distributions. For proportions, a separate proportion confidence interval calculator would be more appropriate.
Last updated: 2025-01-15 · Formula verified against primary sources.