Home / Statistics & Probability / Probability Distributions / Confidence Interval for the Mean

Formula & Calculator

Confidence Interval for the Mean

A confidence interval gives a range of values that is likely to contain the true population mean. It is the sample mean plus or minus a margin of error, which depends on the desired confidence level (e.g., 95%) and the standard error. For example, if a sample of 100 people has a mean height of 170 cm with a 95% confidence interval of 168-172 cm, we are 95% confident the true average height of the population lies in that range. It is one of the most common tools in statistical inference.

Statistics Probability Inference
VORZEP · STATISTICS & INFERENCE TOOLS

Confidence Interval Calculator for the Mean

Compute the confidence interval CI = x̄ ± z · (σ / √n) for the population mean — or solve for margin of error, required sample size, or recover x̄ from given bounds. Includes a live sampling-distribution diagram, a margin-of-error chart, and a full step-by-step solution with optional t-distribution.

CI = x̄ ± z · ( σ / √n ) · also = x̄ ± E · SE = σ/√n
Sample Mean (x̄) The sample mean — the centre of the confidence interval. For interval mode, x̄ is the midpoint of the two CI bounds: x̄ = (L + U)/2.
x̄
Sample mean must be a finite number.
Standard Deviation (σ or s) The population standard deviation σ (z-distribution) or the sample standard deviation s (t-distribution). Must be strictly positive. A larger σ widens the CI, because the estimate of x̄ is less precise.
σ
Standard deviation must be greater than zero.
Sample Size (n) The number of observations in the sample. Must be a positive integer ≥ 2 (≥ 3 for the t-distribution). The standard error σ/√n shrinks as 1/√n, so quadrupling n halves the margin of error.
n
Sample size must be an integer ≥ 2.
95% CONFIDENCE INTERVAL
95.100
E = 4.900 · SE = 2.500 · z = 1.9600 · n = 36
MODERATE PRECISION — E ≈ 4.9% OF x̄
CI = x̄ ± z · (σ / √n)
Step-by-step solution
Sampling distribution of x̄ with CI shaded
Distribution of x̄ (SE = σ/√n) Central CI region
Margin of error vs. sample size
E(n) = z·σ/√n current (n, E)
Sensitivity (+1 % per input)
Full inference metrics
Confidence interval on a number line — live schematic
Sample mean x̄ Confidence interval [L, U] Margin of error E
What a confidence interval really measures
CIinterval estimate
=
x̄point estimate
±
z · SEmargin of error

It is not the probability that μ lies in the interval

The most common misinterpretation is that "there is a 95% probability the population mean lies in this interval." Strictly speaking, μ is fixed and either lies in the interval or does not. The correct frequentist interpretation is: if you repeated the sampling procedure many times, 95% of the resulting intervals would contain the true μ. The 95% is a property of the method, not of this particular interval.

Halving E requires quadrupling n

Because E = z·σ/√n, the margin of error shrinks only as 1/√n. To halve the margin of error you must quadruple the sample size; to reduce it by a factor of 10 you need 100× the data. This is why survey companies stop at ~1,000 respondents — going to 4,000 only halves the error and quadruples the cost. The Advanced chart shows this trade-off directly.

Higher confidence widens the interval

Moving from 90% to 95% to 99% confidence multiplies the critical value by 1.645 → 1.960 → 2.576. Each step captures more of the distribution's probability mass but makes the interval wider, hence less precise. There is no free lunch: the only way to increase both confidence and precision is to increase the sample size. In quality control this is the classic trade-off between Type I and Type II errors.

z vs. t — when to use which

Use the z-distribution when σ is genuinely known (rare in practice) or when n is large (rule of thumb: n ≥ 30). Use the t-distribution when σ is estimated from the sample as s and n is small. The t-critical value is always larger than the corresponding z, so t-intervals are wider — this is the price of not knowing σ. As n → ∞, t converges to z: t₁₀₀(0.975) = 1.984 vs. z(0.975) = 1.960.

How to Use This Calculator

A confidence interval quantifies the uncertainty in a sample mean as an estimate of a population mean. Give the tool your sample statistics and a confidence level, and it will compute the interval, the margin of error, and the required sample size.

1. Load a scenario preset

Click any preset — quality control, IQ, SAT, blood pressure, polling, body temperature — to load typical values. Or type your own x̄, σ and n directly.

2. Pick a confidence level

Choose 80%, 90%, 95%, 98%, 99% or 99.9%. The critical value (z or t) is looked up automatically and displayed in the result card. Higher confidence gives wider intervals.

3. Choose z or t

Use z when the population σ is known or n ≥ 30. Use t when σ is estimated from the sample as s and n is small. The tool computes the correct critical value in both cases.

4. Pick what to solve for

CI gives the full interval and margin of error. E gives only the margin of error. n gives the sample size needed to reach a target margin of error. x̄ recovers the point estimate from given CI bounds.

5. Read the diagram and charts

The number line shows x̄ and [L, U] on a common axis. The sampling-distribution chart shows the bell curve of x̄ with the CI region shaded — visually confirming that the shaded area equals the confidence level.

6. Switch to Advanced for depth

Advanced mode adds the margin-of-error-vs-sample-size chart, a +1% sensitivity check on every input, and a metrics panel with SE, E, the CI, the critical value, and required n for several target precisions.

What This Tool Offers

Built around the classic interval estimator CI = x̄ ± z · (σ / √n), the fundamental tool of statistical inference for a mean.

Four solving modes

Compute the interval, the margin of error, the required sample size, or recover x̄ from given bounds. Each mode hides the fields it does not need and produces the same full set of derived statistics.

z and t distributions

Switch between z (σ known / large n) and t (σ estimated from sample / small n). The t-critical value is computed with the Cornish–Fisher expansion, which is accurate for ν ≥ 3.

Sampling distribution chart

A live bell curve centred at x̄ with standard deviation SE = σ/√n, with the central confidence region shaded. The shaded area equals exactly the chosen confidence level.

Number-line diagram

A horizontal axis showing x̄, the lower and upper bounds L and U, and the shaded CI band — with values labelled. Easy to read at a glance.

E vs n trade-off chart

Advanced mode plots E = z·σ/√n against sample size n, so you can see how quickly precision improves — or fails to improve — as you add more data.

Reference tables

A z-critical-value table for common confidence levels, a required-n table for common margin-of-error targets, typical μ and σ by application, and the full variable reference.

Reference Tables & Conversions

Critical values by confidence level, required sample sizes for target precision, typical reference scenarios, and the variable reference.

Critical Values by Confidence Level

Two-sided z and t critical values. For t, values are shown for several degrees of freedom ν = n − 1.

Confidenceαz (two-sided)t, ν = 5t, ν = 10t, ν = 30t, ν = 100

Required Sample Size for a Target Margin of Error

Computed from n = (z·σ/E)², rounded up to the next integer. Assumes σ = 1 for ease of scaling — multiply E by σ for other cases.

Target E (with σ = 1)90 % CL95 % CL98 % CL99 % CL99.9 % CL

Typical Confidence Interval Scenarios

Representative inputs and the resulting 95% confidence intervals.

Applicationx̄σnSEE (95%)95% CI

Variable Reference

SymbolMeaningFormulaNotes
x̄Sample meanΣxᵢ / nPoint estimate of μ
μPopulation mean—The unknown parameter being estimated
σPopulation standard deviation—Known in z-mode; estimated by s in t-mode
sSample standard deviation√(Σ(xᵢ−x̄)²/(n−1))Used in the t-distribution
nSample sizecountPositive integer ≥ 2
SEStandard error of the meanσ / √nUncertainty of x̄ as an estimate of μ
zCritical value (standard normal)Φ⁻¹(1 − α/2)1.96 for 95% two-sided
tCritical value (Student's t)t⁻¹(1 − α/2, ν)Larger than z; ν = n − 1
EMargin of errorz · SEHalf-width of the interval
CIConfidence interval[x̄ − E, x̄ + E]Interval estimate of μ
CLConfidence level1 − αTypically 0.90, 0.95, 0.99

What Does CI = x̄ ± z · (σ / √n) Measure?

A confidence interval for the mean is an interval estimate of the population mean μ, built from a sample mean x̄ and a measure of its uncertainty. The interval has the form x̄ ± E, where E is the margin of error. The margin of error combines the variability of the underlying data (σ), the size of the sample (n), and the desired confidence level (via the critical value z or t). The result is a range of plausible values for μ, together with a stated confidence level that describes how often the method produces intervals containing μ.

The Confidence Interval Formula

The two-sided confidence interval for the population mean, when σ is known, is:

CI = x̄ ± z1−α/2 · ( σ / √n )

Rearranged to show the individual quantities:

SE = σ / √n   (standard error)
E = z · SE   (margin of error)
CI = [ x̄ − E , x̄ + E ]

When σ is not known and is estimated from the sample as s, replace z with the t-critical value t1−α/2, n−1:

CI = x̄ ± t1−α/2, n−1 · ( s / √n )

The required sample size for a target margin of error E is obtained by solving for n:

n = ( z · σ / E )²   (round up to the next integer)

And the point estimate and margin of error can be recovered from any CI bounds [L, U]:

x̄ = (L + U) / 2   ·   E = (U − L) / 2

Confidence Interval Variables

SymbolMeaningNotes
x̄Sample meanThe point estimate of μ
σPopulation standard deviationKnown in z-mode
sSample standard deviationEstimated from the sample; used in t-mode
nSample sizePositive integer ≥ 2
SEStandard errorσ/√n; shrinks as 1/√n
zCritical value1.645 (90%), 1.960 (95%), 2.576 (99%)
tCritical value for small samplesAlways ≥ z for the same confidence level
EMargin of errorz · SE; half-width of the CI
CIConfidence interval[x̄ − E, x̄ + E]

How Each Input Affects the Interval

The margin of error E = z · σ/√n depends on three quantities. Increasing σ widens the interval proportionally: doubling σ doubles E. Increasing the confidence level raises z and widens the interval — moving from 90% to 95% inflates E by about 19%. Increasing the sample size narrows the interval as 1/√n: quadrupling n halves E, and reducing E by a factor of 10 requires 100× the sample.

The choice between z and t matters only for small samples. For n ≥ 30, t and z differ by less than 3%; for n ≥ 100 they differ by less than 1%. For small n, t can be noticeably larger — at ν = 5, t(0.975) = 2.571 vs z(0.975) = 1.960, so a t-interval is about 31% wider than the corresponding z-interval. This extra width is the correct penalty for estimating σ from a small sample.

Confidence level and precision trade off against each other directly. A 99% interval is wider than a 95% interval, which is wider than a 90% interval. There is no way to increase confidence and narrow the interval at the same time — the only lever that improves both is a larger sample size.

Confidence Interval Calculation Examples

Quality control: x̄ = 50.0 mm, σ = 0.1 mm, n = 30, 95% CL
SE = 0.1 / √30 = 0.01826
E = 1.96 × 0.01826 = 0.0358
CI = 50.0 ± 0.0358 = [49.964, 50.036] mm
IQ estimate: x̄ = 100, σ = 15, n = 36, 95% CL
SE = 15 / √36 = 2.500
E = 1.96 × 2.500 = 4.900
CI = 100 ± 4.900 = [95.100, 104.900]
Required sample size for E = 3, σ = 15, 95% CL
n = (1.96 × 15 / 3)² = (9.80)² = 96.04 → n = 97
Recover x̄ and E from CI = [42.3, 47.7]
x̄ = (42.3 + 47.7) / 2 = 45.0 · E = (47.7 − 42.3) / 2 = 2.7

Frequently Asked Questions

It means: if you repeated the sampling procedure many times and constructed a 95% interval each time, 95% of those intervals would contain the true population mean μ. It is a statement about the long-run behaviour of the method, not about any single interval. The common but incorrect interpretation is that "there is a 95% probability that μ lies in this specific interval" — this treats μ as random, which it is not in the frequentist framework. A Bayesian credible interval does support that interpretation, but it is a different object.

Use z when the population standard deviation σ is genuinely known — for example from a large historical dataset, a calibration certificate, or a well-characterised manufacturing process — or when the sample size is large (n ≥ 30 is the usual rule of thumb). Use t when σ must be estimated from the sample as s and n is small. In practice, σ is almost never known exactly, so t is the safer default for small samples. As n grows, t converges to z and the distinction becomes negligible.

Because E = z·σ/√n, so E scales as 1/√n. Halving E requires making √n twice as large, which requires n to be four times as large. In general, reducing E by a factor k requires multiplying n by k². This is the "square-root law" of sampling and it applies to every statistical estimate. It is why survey companies stop at around 1,000 respondents — going to 4,000 quadruples the cost to halve the error, and going to 10,000 gives only a 3.2× reduction in the margin of error.

Yes, and this is a sign that a normal-based interval may not be appropriate. If you are estimating a proportion near 0 or 1, a mean of a strictly positive quantity, or any parameter with a bounded range, the symmetric x̄ ± E interval can extend beyond the valid range. In such cases, use a transformation (e.g. log or logit) before computing the interval and transform back, or use an asymmetric interval such as the Wilson interval for proportions or a bootstrap confidence interval. The normal approximation underlying this calculator assumes the estimate is approximately normally distributed, which typically requires n ≥ 30 and no extreme skew.

A confidence interval estimates a population parameter — in this case the population mean μ — and has width proportional to σ/√n. A prediction interval estimates the range in which a single future observation is likely to fall, and has width proportional to σ·√(1 + 1/n). Prediction intervals are therefore much wider than confidence intervals, especially for large n. For n = 100 and 95% confidence, the CI width is about 0.196σ while the PI width is about 1.98σ — a factor of 10 difference. Choose based on whether you are estimating a parameter or forecasting an individual value.

Not necessarily. A wider interval is less precise, but precision is not the only criterion. A wider interval at a higher confidence level reflects a stronger guarantee — you are more certain that the interval contains μ. The right way to judge an interval is whether its width is acceptable for the decision at hand, given the stated confidence level. A 99% interval that is twice as wide as a 95% interval is not worse; it is answering a different question. What would be a bad estimate is a very narrow interval that fails to contain μ — which is more likely with a lower confidence level.

The standard survey sample size of about 1,000 respondents comes from the formula n = (z·σ/E)² with σ = 0.5 (maximum variance for a proportion), z = 1.96 (95% confidence), and E = 0.03 (3 percentage points). This gives n = (1.96 × 0.5 / 0.03)² ≈ 1,067. If you want a 5-point margin of error, n ≈ 385 is enough. If you want a 1-point margin, you need n ≈ 9,604. This is why political polls typically report margins of error of 2–4 percentage points — that is the precision achievable at reasonable cost.

Calculating...

Variables

Symbol Quantity Unit
CI Confidence interval
x̄ Sample mean
z Z-score for confidence level
σ Population standard deviation
n Sample size

What it means

A confidence interval for the population mean provides a range of values that is likely to contain the true mean, based on a sample statistic. The formula uses the sample mean x̄, a critical value z (from normal distribution) for the desired confidence level, and the standard error σ/√n. It assumes known population standard deviation. For unknown σ, the t‑distribution is used. The interval width reflects the uncertainty due to sampling. It is widely used in reporting study results, in quality control, and in survey analysis. Understanding confidence intervals is crucial for interpreting the precision of estimates and for making inferential conclusions.

Worked example

Confidence Interval for Mean – Two Examples

Real‑World
Scenario: A sample of 100 items has mean 50, σ=10. Construct a 95% CI (z=1.96).
ParameterValue
x̄50
σ10
n100
z1.96
1Margin = 1.96 × (10/√100) = 1.96 × 1 = 1.96
2CI = 50 ± 1.96 = (48.04, 51.96)
Result (48.04, 51.96) ✓ 95% confidence
Scenario: A sample of 25 has mean 100, σ=20. Find 95% CI.
ParameterValue
x̄100
σ20
n25
z1.96
1Margin = 1.96 × (20/√25) = 1.96 × 4 = 7.84
2CI = 100 ± 7.84 = (92.16, 107.84)
Result (92.16, 107.84) ✓ 95% CI
Insight: A confidence interval gives a range of plausible values for the population mean. The 95% CI means that in repeated sampling, 95% of intervals would contain the true mean.

Common mistakes

  • Confidence interval for the mean: Estimate of the population mean with a given confidence level.
  • z: The z‑score for the desired confidence level (e.g., 1.96 for 95%).
  • σ: Population standard deviation – if unknown, use t‑distribution and sample standard deviation.
  • n: Sample size – must be large enough for z (or use t).
  • Interpretation: The interval has a (1−α)·100% chance of containing the true mean.

Applications

A confidence interval for the mean provides a range of plausible values for the population mean, based on sample data, with a specified level of confidence (e.g., 95%). It is a cornerstone of inferential statistics, used to quantify the uncertainty of estimates. Engineers use confidence intervals to assess process performance, to compare designs, and to validate simulation models. In research, they report the precision of estimates. By constructing confidence intervals, professionals can make informed decisions, recognise the limitations of sample data, and communicate the reliability of findings. The interval width is determined by the sample size, standard deviation, and confidence level. Understanding confidence intervals is essential for evidence‑based decision‑making.

  • Quality control – estimating true mean of a process
  • Research – reporting means with uncertainty
  • Engineering design – comparing alternative designs
  • Market research – estimating population parameters
  • Risk analysis – assessing uncertainty in predictions