Confidence Interval Calculator: Formula & How-To
The calculator for this page is switched off while it is checked. The formula is below, and the worked example in the article shows how to use it by hand.
This calculator works out a confidence interval for a population mean when you know your sample mean, sample size, and standard deviation (or when you provide the raw data). Enter your sample statistics and choose a confidence level, and you get the lower and upper bounds of the interval, plus the margin of error. The result tells you the range within which the true population mean likely falls, given your chosen level of confidence.
Formula
The confidence interval for a population mean (when the population standard deviation is unknown and you use the sample standard deviation) is:
CI = x̄ ± z* × (s / √n)
- x̄ = sample mean (the average of your data)
- z* = critical value for your chosen confidence level (1.645 for 90%, 1.960 for 95%, 2.576 for 99%)
- s = sample standard deviation (a measure of spread in your data)
- n = sample size (number of observations)
The term s / √n is the standard error of the mean. Multiplying it by z* gives the margin of error. The interval is centered on the sample mean and extends equally in both directions.
Worked Example
Using the default values from the calculator: n = 30, x̄ = 100, s = 15, and a 95% confidence level (z* = 1.960).
- Calculate the standard error: s / √n = 15 / √30 ≈ 15 / 5.477 ≈ 2.7386
- Multiply by the critical value: 2.7386 × 1.960 ≈ 5.368
- Lower bound: 100 − 5.368 = 94.63
- Upper bound: 100 + 5.368 = 105.37
The 95% confidence interval is [94.63, 105.37]. The margin of error is ±5.37.
When to Use This Calculator
Use this tool when you have a sample from a larger population and you want to estimate the population mean. Common situations include:
- Survey results (e.g., average income, satisfaction score)
- Quality control (e.g., average weight of a product)
- Scientific experiments (e.g., mean reaction time)
- Business metrics (e.g., average order value)
The formula works best when your data is roughly normally distributed and your sample size is at least 30 (thanks to the Central Limit Theorem). For smaller samples, a t-distribution is more accurate, but this calculator uses the normal approximation for simplicity and broad applicability.
How to Read the Result
The interval [94.63, 105.37] does not mean there is a 95% chance the true mean lies inside it. The correct interpretation: if you repeated this sampling process many times and calculated a confidence interval each time, about 95% of those intervals would contain the true population mean. For your specific interval, the true mean is either inside or outside—you just don’t know which.
The width of the interval tells you about precision. A narrow interval (e.g., ±2) means your estimate is precise; a wide interval (e.g., ±20) means it’s imprecise. The width depends on:
- Sample size: larger n → narrower interval
- Standard deviation: smaller s → narrower interval
- Confidence level: higher confidence → wider interval
Common Mistakes and Misconceptions
- Using the population standard deviation (σ) instead of the sample standard deviation (s): if you know σ (rare in practice), the formula uses σ directly; otherwise, you must use s. Mixing them up changes the width.
- Forgetting to take the square root of n: the standard error is s/√n, not s/n. This is a frequent arithmetic slip.
- Interpreting the interval as a probability: as noted above, the confidence level applies to the method, not to any single interval.
- Using the wrong critical value: for a 95% confidence level, z* = 1.960 (not 1.645, which is for 90%).
- Ignoring the sample size condition: for n < 30, the normal approximation may be unreliable unless the data is clearly normal. Consider using a t-table instead.
Limitations of the Formula
This calculator assumes a simple random sample from a large (or infinite) population. If your sample is biased, the interval will be misleading regardless of the math. Also, the formula does not work well with:
- Heavily skewed data (unless n is very large)
- Outliers (they inflate s and widen the interval)
- Small samples (n < 30) from non-normal populations
- Dependent observations (e.g., repeated measures from the same subject)
For proportions (e.g., percentage of voters), a different formula is needed—this calculator is only for means.
Alternatives and Extensions
If your sample size is small (n < 30), use a t-distribution instead of the normal distribution. The t critical value depends on your degrees of freedom (n−1) and confidence level. For example, with n = 10 and 95% confidence, the t critical value is about 2.262, which is larger than 1.960, giving a wider interval.
Other related tools include:
- One-sided confidence intervals: if you only care about an upper or lower bound.
- Confidence interval for proportions: for binary outcomes.
- Prediction intervals: for individual future observations, which are wider than confidence intervals.
- Bootstrap intervals: resampling-based, useful when the distribution is unknown.
Frequently Asked Questions
What is the difference between a confidence interval and a margin of error?
The margin of error is the half-width of the interval—the amount you add and subtract from the sample mean. The confidence interval is the full range from the lower bound to the upper bound. In the example above, the margin of error is ±5.37, and the interval is [94.63, 105.37].
Why does a larger sample size give a narrower interval?
Because the standard error (s/√n) decreases as n increases. The square root means you need to quadruple your sample size to halve the margin of error. This is why large surveys can be expensive—they require many more responses to gain a small improvement in precision.
Can I use this calculator for a proportion (e.g., percentage of people who vote)?
No. This calculator is for a mean (average) of a numeric variable. For proportions, the formula is different: p̂ ± z* × √(p̂(1−p̂)/n), where p̂ is the sample proportion. That calculator is available elsewhere on this site.
What if my sample size is less than 30?
If your data is approximately normal, you can still use this calculator, but the result will be too narrow because the normal critical value is smaller than the t critical value. For example, with n = 10 and 95% confidence, the t value is 2.262, so the interval should be about 15% wider. For non-normal data, consider a nonparametric method.
How do I choose the confidence level?
The most common choice is 95%, which balances precision and certainty. Use 90% if you need a narrower interval and can accept more risk of being wrong. Use 99% if you need high certainty and can tolerate a wider interval. The choice depends on the consequences of being wrong—for medical or safety decisions, higher confidence is often preferred.
What does “95% confidence� actually mean in practice?
It means that if you were to repeat your sampling process 100 times and calculate a 95% confidence interval each time, approximately 95 of those intervals would contain the true population mean. It does not mean there is a 95% chance that any particular interval contains the true mean.
Related
Formula used
in n | Sample size (n) | - | 30 | 1 in m | Sample mean (x̄) | - | 100 | 0 in s | Sample std dev (s) | - | 15 | 0 sel cl | Confidence level | 90%=1.645, 95%=1.960, 99%=2.576 | 1.960 out ci | Confidence interval | - | m - s/sqrt(n)*cl, m + s/sqrt(n)*cl | 2 out me | Margin of error | - | s/sqrt(n)*cl | 2
Each line is one input (in, sel, list) or one result (out: label, unit, formula, decimals). How the calculators work
Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.