Skip to main content

Confidence Interval Calculator - Mean and Proportion

Build a 90%, 95%, or 99% interval for a mean (z or t) or a proportion (Wald). Shows the margin of error. Runs locally.

Sample Summary

Default mean: x̄ = 50, s = 10, n = 40, 95%. Auto-z is about 46.9 to 53.1. Proportion CIs are Wald, not Wilson.

IntervalCalculated

46.9010267062 to 53.0989732938
95% mean interval
Method: z (auto: n = 40 ≥ 30)
Point estimate: 50
Standard error: 1.58113883008
Critical value: 1.95996280327
Margin of error: ± 3.09897329378

What a Confidence Interval Is (and Is Not)

A confidence interval calculator takes a point estimate - a sample mean x̄ or a sample proportion p̂ - and attaches a margin of error so you can report a range instead of a lonely number. The range is not a probability statement about the unknown parameter after you have computed it. The parameter is fixed; the interval would jitter if you drew a new sample. “95% confidence” describes the method’s long-run hit rate, not a 95% chance that this one printed interval contains μ or p.

This page builds two families of intervals. For a mean, the half-width is a critical value times s/√n (or σ/√n). For a proportion, it uses the Wald normal approximation p̂ ± z √(p̂(1−p̂)/n). The default mean case is x̄ = 50, s = 10, n = 40, 95%: with z* ≈ 1.96 the interval is about 46.9 to 53.1. Forcing t with df = 39 makes it a little wider.

Arithmetic stays in the browser. Nothing is uploaded. If you need a sample size that would hit a target margin, use the sample size calculator. If you only have a list of raw values, compute s first with a spread tool, then paste s and n here.

How to Build an Interval on This Page

  1. Choose mean or proportion, then 90%, 95%, or 99% confidence.
  2. For a mean, enter x̄, a positive s or σ, and integer n ≥ 2. Pick auto / z / t. Auto uses z when n ≥ 30 and t otherwise; you can override.
  3. For a proportion, enter successes x (0 through n) or p̂ in [0, 1], plus n. If n p̂ or n(1−p̂) is under 5 you still get a Wald interval, plus a warning - not a hard fail.
  4. Read lower and upper bounds, standard error, critical value, and margin of error. Copy the block, or clear the fields to start over.

Mean intervals assume the sampling distribution of x̄ is approximately normal. Proportion intervals here are Wald, not Wilson, Agresti–Coull, or exact binomial.

Mean Intervals: x̄ ± (z* or t*) × (s/√n)

x̄ ± z* σ / √n
or x̄ ± t* s / √n with df = n − 1

The standard error of the mean is spread over √n. Doubling n does not cut the margin in half; you need four times the sample for that. z* comes from the standard normal: for 95% two-sided coverage, Φ(z*) = 0.975, so z* ≈ 1.96. This page finds that quantile by bisection on an erf-based CDF rather than hard-coding 1.96.

When σ is unknown, replace it with s and replace z* with t* at df = n − 1. t* is defined by P(|T| > t*) = 1 − confidence. The calculator locates t* by bisection on the Student-t CDF, which is implemented with a regularized incomplete beta (Lanczos log-gamma, continued-fraction betacf). For n = 40, df = 39, 95%, t* is a bit above 2.02, so the interval is slightly wider than the z version of the default example.

Known σ and a z interval belong together. Using t with a claimed known σ is conservative; using z with a tiny-sample s is optimistic. Auto mode follows the common n ≥ 30 split so homework matches a textbook’s “large sample, use z” line.

Proportion Intervals: Honest about Wald

p̂ ± z √(p̂(1 − p̂) / n)

Wald’s interval is the first one most intro-stats courses write down. It can undershoot coverage when p̂ is near 0 or 1 or when n is small, and the bounds can fall outside [0, 1]. This calculator does not clip them and does not switch to Wilson. If you need a better-behaved binomial interval, say so in the write-up and use software that offers Wilson or Clopper–Pearson; this page will not pretend it did.

The np̂ ≥ 5 and n(1−p̂) ≥ 5 check is a teaching rule of thumb, not a theorem. Violating it produces a warning, not a refusal. You can still copy the Wald numbers and discuss why they may be untrustworthy.

p̂ must lie in [0, 1]. Entering 20 successes in 40 trials is the same as typing 0.5. Pair this with a z-score calculator if you want the critical z spelled out as a standard score, or with the p-value calculator if the next step is a test rather than an interval.

Margin of Error, Width, and Coverage

The margin of error is the quantity you add and subtract: critical value × standard error. Interval width is twice that. Raising confidence from 95% to 99% inflates the critical value (about 1.96 → 2.58 for z) and therefore the margin. That is the trade: fewer misses, a fatter range.

Does this 95% interval contain the true mean? You cannot know from one sample. In a simulation, about 95 of 100 correctly built 95% intervals would cover; the other five would miss entirely, and those five still look like ordinary numeric ranges. Coverage also collapses if the normal approximation is a lie - skewed data, a mean of a tiny n, or a Wald interval for 2 successes in 80 trials.

For a mixed toolbox of descriptive stats, see the statistics calculator.

Worked Numbers You Can Check by Hand

Mean, z, 95%, default inputs

SE = 10 / √40 ≈ 1.5811. z* ≈ 1.960. Margin ≈ 3.099. Interval ≈ 46.90 to 53.10. That is the “about 46.9 to 53.1” check.

Same data, forced t

df = 39. t* is a little over 2.02. Margin grows to about 3.20. The interval is a bit wider than z, which is what you want when s is estimated.

Proportion, 20 / 40, 95%

p̂ = 0.5, SE = √(0.25/40) = 0.07906, z* ≈ 1.96, margin ≈ 0.155, interval about 0.345 to 0.655. np̂ = 20 ≥ 5, so no Wald warning.

Proportion that should warn

2 successes in 80 trials: p̂ = 0.025, np̂ = 2 < 5. The Wald interval still appears, with a warning that the normal approximation is a poor fit.

Where These Intervals Show Up

1. Lab means with a stated precision

A chemistry section that reports 50.0 ± 3.1 (95% CI) is quoting a margin of error, not a standard deviation. Mixing those two symbols is a common lab-report error.

2. Polling and conversion rates

“52% ± 3%” is usually a Wald-style proportion margin. If the sample is 40 people, that ±3% would be fantasy; n has to match the SE formula.

3. A/B tests and quality sampling

A defect rate interval that includes a spec limit is a different decision than a point estimate that merely sits near it. Still: Wald near 0% defects is exactly where the warning is trying to help. A 95% interval that includes 0 is not proof the effect is zero; it is a reminder that the data are compatible with zero under this model. Report the margin of error next to the point estimate so a reader can see whether “52%” was 52% ± 2% or 52% ± 15%.

What This Interval Tool Does Not Compute

It does not build a two-sample interval for μ₁ − μ₂, a paired difference interval, a variance interval, or a bootstrap percentile interval. It does not apply a finite-population correction: if you sampled 40 people from a village of 200, the usual s/√n overstates the SE, and this page will not shrink it by √((N−n)/(N−1)). It does not clip a Wald proportion interval into [0, 1], so a noisy p̂ near 0 can produce a negative lower bound - that is a known Wald pathology, left visible on purpose.

It also does not pick your confidence level for you. 95% is a convention, not a law of nature. Regulatory work sometimes wants 99%; an underpowered pilot might honestly report 90% and a huge margin rather than fake precision. Changing 95% to 99% on the default mean example moves z* from about 1.96 to about 2.58 and the half-width from about 3.1 to about 4.1, so the interval grows from roughly 46.9–53.1 to roughly 45.9–54.1.

Independence of observations is assumed and never checked. Cluster-sampled classrooms, overlapping time series, and “n = 40” that is really 8 people measured five times each all break the SE formula. The calculator cannot see your design; it only sees x̄, s, and n.

How Sample Size Moves the Margin

Margin of error scales with 1/√n. Keep s = 10 and 95% z. At n = 10, SE = 3.16 and the margin is about 6.2. At n = 40 (the default) the margin is about 3.1. At n = 160 it is about 1.55. Quadrupling n halves the margin; doubling n only cuts it by about 29%. If a protocol demands a margin of 1.0 with s ≈ 10 and z ≈ 1.96, you need n ≈ (1.96×10/1)² ≈ 384, which is a sample-size problem rather than an interval problem.

For proportions the same 1/√n story holds, but the SE also depends on p̂(1−p̂), which peaks at 0.5. A 95% Wald interval for p̂ = 0.5 and n = 40 has margin ≈ 0.155. For p̂ = 0.1 the formula gives a smaller number, yet that is exactly when the np̂ ≥ 5 warning may fire and the Wald coverage may sag. A smaller printed margin is not automatically a better interval.

t versus z also interacts with n. At n = 5, df = 4, 95% t* is near 2.78, far above 1.96, so forcing z on a tiny sample understates the margin. At n = 40 the gap is modest, which is why textbooks shrug and allow z. Auto mode encodes that shrug; Force t refuses to shrug.

Frequently Asked Questions (FAQ) - Confidence Intervals

What does a 95% confidence interval actually mean?

It does not mean there is a 95% chance the unknown parameter sits inside this one interval you just computed. The parameter is fixed; the interval is random. The 95% refers to the method: if you repeated the study many times and built an interval the same way each time, about 95% of those intervals would cover the true value. This particular interval either covers it or it does not.

Should I use z or t for a mean confidence interval?

Use z when the population standard deviation σ is known, or as a large-sample approximation when n ≥ 30. Use t with df = n − 1 when you only have the sample standard deviation s. t* is larger than z* at the same confidence, so the t interval is wider. This page finds t* by bisection on the Student-t CDF so that P(|T| > t*) equals 1 minus the chosen confidence.

What is the margin of error?

The margin of error is the half-width of the interval: critical value times standard error. For a mean that is z* σ/√n or t* s/√n. For a Wald proportion interval it is z* √(p̂(1−p̂)/n). Adding and subtracting that margin from the point estimate produces the reported lower and upper bounds.

How is a proportion confidence interval computed here?

This tool uses the Wald (normal-approximation) interval: p̂ ± z √(p̂(1−p̂)/n), with p̂ in [0, 1]. It is not a Wilson, Agresti–Coull, or Clopper–Pearson interval. If n p̂ < 5 or n(1−p̂) < 5 the calculator still returns a Wald interval but shows a warning, because the normal approximation is then a poor fit.

Does a 95% CI contain the true mean?

You cannot tell from one sample. Coverage is a property of the procedure, not a probability attached to a finished numeric interval. A 95% interval can miss the true mean; a 99% interval is wider and misses less often under the same assumptions. The mean interval here also assumes the sampling distribution of x̄ is approximately normal.

Does this confidence interval calculator upload my numbers?

No. Intervals are computed in the browser. Sample means, standard deviations, counts, and proportions are not sent to a server. After the page loads, the calculator still runs offline. Values are saved only in this browser’s localStorage for up to 30 days.

Why Use This Confidence Interval Calculator?

  • Mean and proportion in one page, with 90/95/99% levels.
  • z or t, including auto at n ≥ 30 and a real t* from the t CDF.
  • Margin of error shown next to the bounds, not hidden in the half-width.
  • Wald, labeled as Wald - np̂ < 5 warns instead of failing silently.
  • Private. No upload; localStorage only on this device.
  • Copy and Clear with a resizable split layout on desktop.