ThisCalculator

Statistics

Confidence Interval Formula & Calculator

Updated · Standard formula, shown below

Margin of error 3.58
Lower bound
46.42
Result
Upper bound
53.58
Result
Sample mean
50
You entered

Confidence Interval Formula & Calculator

This calculator works out a confidence interval for a population mean when you know your sample mean, sample size, standard deviation, and chosen confidence level. You enter those four values, and you get back 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 is likely to fall, given your sample data.

Formula

The confidence interval is calculated as:

CI = x̄ ± z * (s / √n)

Where:

  • xÌ„ (x-bar) is the sample mean – the average of your sample data, in the same units as your measurements.
  • z is the z-score corresponding to your chosen confidence level. For 95% confidence, z = 1.96; for 90%, z = 1.645; for 99%, z = 2.576.
  • s is the sample standard deviation – a measure of how spread out your sample values are, in the same units as xÌ„.
  • n is the sample size – the number of observations in your sample, a unitless count.

The term z * (s / √n) is called the margin of error. The lower bound is x̄ minus the margin of error, and the upper bound is x̄ plus the margin of error.

Worked Example

Using the default values from the calculator above: sample mean = 50, sample standard deviation = 10, sample size = 30, confidence level = 95%.

  1. Find the z-score for 95% confidence: z = 1.96.
  2. Calculate the standard error: s / √n = 10 / √30 = 10 / 5.477 = 1.826.
  3. Multiply by the z-score: 1.96 * 1.826 = 3.58 (rounded to two decimal places). This is the margin of error.
  4. Lower bound: 50 – 3.58 = 46.42.
  5. Upper bound: 50 + 3.58 = 53.58.

The 95% confidence interval is 46.42 to 53.58. This matches the calculator’s output for the default inputs.

When to Use This Formula

This z-based formula is appropriate when you meet two conditions. First, your sample size is large enough – a common rule of thumb is n ≥ 30, because the Central Limit Theorem ensures the sampling distribution of the mean is approximately normal regardless of the underlying population distribution. Second, you either know the population standard deviation (rare in practice) or you have a large enough sample that using the sample standard deviation s as an estimate is acceptable.

If your sample size is smaller than 30 and you are estimating the standard deviation from the sample, you should use the t-distribution instead of the z-distribution. The t-distribution has fatter tails, which produces wider intervals to account for the extra uncertainty. Most statistical software and many online calculators use the t-distribution automatically for small samples.

How to Read the Result

A 95% confidence interval does not mean there is a 95% chance that the true mean lies within your specific interval. The true mean is fixed; it either lies inside or outside. The correct interpretation is: if you repeated this sampling process many times and calculated a confidence interval each time, approximately 95% of those intervals would contain the true population mean. Your single interval is one of those possible intervals.

In practical terms, a narrow interval indicates a precise estimate – your sample mean is likely close to the true mean. A wide interval indicates more uncertainty, often due to a small sample size or high variability in the data.

Common Mistakes and Pitfalls

  • Using the wrong z-score: 1.96 is for 95% confidence, not for 90% or 99%. Always match the z-score to your confidence level.
  • Confusing standard deviation and standard error: The standard error is s / √n, not s alone. Using s directly gives an interval that is far too wide.
  • Unit mix-ups: If your sample mean is in kilograms, your standard deviation must also be in kilograms. Mixing units (e.g., pounds and kilograms) invalidates the result.
  • Rounding too early: Round intermediate values only at the end. Rounding the standard error to 1.8 instead of 1.826 changes the margin of error noticeably.
  • Ignoring the sample size: A larger sample size gives a narrower interval because √n is in the denominator. Doubling n does not halve the margin of error – it reduces it by a factor of √2 ≈ 1.41.

Limits of the Formula

This formula assumes a simple random sample from the population of interest. If your sample is biased – for example, collected only from one geographic region or one time period – the confidence interval is meaningless, no matter how large n is. The formula also assumes the observations are independent; in clustered or repeated-measures data, the effective sample size is smaller than the raw count.

For proportions (e.g., percentage of voters who support a candidate), the formula is different – it uses p̂ (sample proportion) and the standard error is √(p̂(1-p̂)/n). This calculator is for means only.

Frequently Asked Questions

What is the difference between a confidence interval and a prediction interval?

A confidence interval estimates a population parameter (like the mean). A prediction interval estimates a single future observation. Prediction intervals are always wider because individual values vary more than averages. For example, a 95% confidence interval for the mean height of adult women might be 162–164 cm, but a 95% prediction interval for the height of the next randomly selected woman might be 150–176 cm.

Why do I get a different result with a t-distribution calculator?

For small samples (n < 30), the t-distribution gives wider intervals than the z-distribution because it accounts for the extra uncertainty from estimating the population standard deviation with s. As n grows, the t-distribution approaches the normal distribution, and the two results converge. If your sample size is small, prefer the t-based interval.

Can I use this formula for any confidence level?

Yes, but you need the correct z-score. Common values are 1.645 for 90%, 1.96 for 95%, and 2.576 for 99%. For other levels, use a z-table or statistical software. The calculator above uses 1.96 fixed, so for other levels you would need to adjust the formula manually.

What if my data is not normally distributed?

If your sample size is large (n ≥ 30), the Central Limit Theorem means the sampling distribution of the mean is approximately normal, so the formula still works. For small samples from heavily skewed distributions, the interval may be inaccurate. In that case, consider a nonparametric method like the bootstrap or a sign test.

Does the confidence interval tell me where the data points are?

No. The confidence interval is about the mean, not about individual data points. It does not describe the spread of your data. For example, a 95% confidence interval for the mean might be 46–54, but individual observations could range from 20 to 80. The interval only narrows down where the true average lies.

Related

Formula used
in xbar | Sample mean | - | 50 | 0
in s | Sample standard deviation | - | 10 | 0
in n | Sample size | - | 30 | 1
in cl | Confidence level (%) | - | 95 | 0
out me | Margin of error | - | (s / sqrt(n)) * 1.96 | 2
out lower | Lower bound | - | xbar - me | 2
out upper | Upper bound | - | xbar + me | 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.