Confidence Interval Calculator

Share:
Mathematics

Confidence Interval Calculator

CI for mean + proportion

By Checked against sources by Last reviewed CONFIDENCE INTERVAL MARGIN OF ERROR MATH STATISTICS
Your browser is too old for this tool’s interactive features. Please update to Safari 13.1, Chrome or Edge 80, Firefox 74 or newer.

Confidence Interval Calculator

📈 Confidence Interval for the Mean (continuous data)

Confidence Interval for μ
[—, —]
Margin of error
—
Standard error
—
Critical value
—
Enter sample mean, SD, and n ≥ 2

📊 Confidence Interval for a Proportion (binary outcome data)

—
Wilson Score CI (preferred)
[—, —]
Normal CI low
—
Normal CI high
—
Margin of error
—
Enter successes (≤ trials) and trials (≥ 1)
Advertisement
After results · AD-W1Responsive · Post-tool — peak engagement

How to use the Confidence Interval Calculator

Pick the right mode: mean or proportion

Mean CI: for continuous data — test scores, response times, prices, measurements, returns. You need three numbers: sample mean (x̄), sample standard deviation (s), and sample size (n). Proportion CI: for binary outcomes — yes/no, pass/fail, click/no-click, vote share. You need two numbers: successes (how many "yes" outcomes) and trials (total count). Most A/B test results, election polls, and survey proportions use this mode.

Choose your confidence level

95% is the conventional default — NIST's e-Handbook notes that 90, 95 and 99% intervals are the common choices, with 95% the most used. 90% suits exploratory work; 99% suits a decision where a wrong call is costly. The trade-off: higher confidence = wider interval. A 99% CI is ~1.3× wider than a 95% CI for the same data. Reporting both the interval AND the confidence level is essential — "the mean is between 75 and 85" is meaningless without saying at what confidence.

For means: use t-distribution if n < 30

The "Use t-distribution" checkbox is on by default — it's the safer choice. The t-distribution accounts for the extra uncertainty of estimating the population SD from a sample. t-intervals are always wider than z-intervals, and the gap shrinks as n grows without ever reaching zero: at 95%, t is about 4% wider than z at n = 31 and about 1.2% wider at n = 100. The only reason to UNCHECK is if you genuinely know the population SD σ (rare — most real-world analyses estimate σ from the sample).

For proportions: prefer Wilson score over normal approximation

The proportion CI has two formulas. The normal approximation p̂ ± z×√(p̂q̂/n) is the textbook formula but performs poorly when p̂ is close to 0 or 1, or when n is small (under 30). The Wilson score interval is more accurate across all conditions and is the modern recommendation (Brown, Cai, and DasGupta 2001). Use Wilson values; normal approximation is shown for comparison and historical context. They agree closely for large samples and moderate proportions.

Advertisement
After how-to · AD-W2Responsive

Confidence intervals — what they say and what they don't

A confidence interval is a range of values that's likely to contain the true population parameter (mean, proportion, etc.) you're trying to estimate. The "95% confidence" doesn't mean there's a 95% probability the parameter is in this specific interval (a common misinterpretation) — it means that if you repeated your sampling procedure many times, ~95% of the resulting intervals would contain the true parameter. The distinction is subtle but important: the parameter is fixed (it's not random), while the interval moves around with each sample. The strict interpretation is hard to internalise; the practical use is simpler: a 95% CI gives you a range you can reasonably trust as plausible values for the parameter.

The margin of error and sample size relationship

The width of a confidence interval is governed by three factors: the variability in the data (SD or proportion magnitude), the sample size, and the chosen confidence level. The most important relationship: margin of error scales with 1/√n. To halve the margin of error, you need 4× the sample size. To quarter it, you need 16×. This is why political polls report ±3% with n≈1000 (1/√1000 ≈ 0.032, and z×SE for proportions is roughly 1.96 × 1/√n × 0.5 ≈ 0.031 in the worst case). Bigger samples give tighter intervals but with rapidly diminishing returns — going from 1000 to 4000 only halves the margin, at 4× the cost. This trade-off underlies sample size planning across every empirical discipline.

Margin of error scales with 1/√n. To halve the margin, quadruple the sample. To get 1% margins, you need ~10,000 samples — which is why high-precision polling is expensive.

Why Wilson score beats normal approximation for proportions

The textbook proportion CI uses the normal approximation: p̂ ± z×√(p̂(1−p̂)/n). It's simple to compute but performs poorly in two situations: (1) when p̂ is close to 0 or 1, the normal approximation can produce intervals that include negative values or values above 1 — which are impossible for proportions. With 2 successes in 100 trials its 95% lower limit is −0.74%. (2) When the sample is small or the success count is small, the actual coverage of the normal CI falls below the level it claims. Computed exactly from the binomial: at n = 30 and a true rate of 10%, a nominal 95% normal interval contains the truth only about 81% of the time, while the Wilson interval contains it about 97% of the time. The Wilson score interval (Wilson 1927) cannot leave [0, 1] and holds its coverage far better. Brown, Cai and DasGupta's 2001 paper "Interval Estimation for a Binomial Proportion" found the normal interval's coverage erratic even at large n and recommends Wilson (or the Jeffreys interval) for small samples; NIST's e-Handbook gives Wilson as its method. The calculator shows both, so you can see the difference.

A worked example (illustrative numbers, not real survey data)

Take the figures the calculator loads by default: 520 "yes" answers out of 1,000 — a made-up survey, chosen only to show the arithmetic. The sample proportion is p̂ = 52.00%. At 95% confidence the normal approximation gives a margin of error of ±3.10% and an interval of [48.90%, 55.10%]; the Wilson score interval gives [48.90%, 55.08%]. Both intervals straddle 50%, so on this evidence you cannot say the "yes" side is ahead — a lead of two percentage points is inside the noise at this sample size. That is the whole practical value of a confidence interval: it converts a single point estimate into a range, and here the range spans the one number that would have made the result interesting. Notice too how close the two methods are: at n=1,000 with p̂ near 0.5 the normal approximation and Wilson agree to a hundredth of a percentage point, which is exactly the regime where the textbook formula is safe. Shrink the sample to 20 trials, or push p̂ out towards 0 or 1, and the two start to diverge — that is when reaching for Wilson stops being a formality.

What 95% does not mean, the 1/√n rule, and Wilson over the normal approximation

01

95% confidence interval doesn't mean "95% chance the parameter is in this interval" — it means 95% of CIs from repeated samples would contain it.

02

Margin of error scales with 1/√n. To halve the margin, quadruple the sample size. Big polls cost a lot to be slightly more precise.

03

For sample mean: use the t-distribution when n < 30 or σ unknown. Use z only when σ is genuinely known.

04

For proportions: the Wilson score interval beats the normal approximation, especially for small samples or extreme p̂.

05

The most common CI level is 95%; NIST's e-Handbook names 90, 95 and 99% as the usual choices.

06

Election polls typically report ±3% margin at 95% CI from n≈1000. Going to ±1% margin requires n≈9,600.

07

A CI excluding zero (for a difference) is equivalent to a statistically significant result at the corresponding p-value cutoff.

08

Width of 99% CI ≈ 1.3× width of 95% CI for the same data. 99.9% CI is ≈1.7× wider. Higher confidence costs precision.

09

Bayesian credible intervals are conceptually different — they DO express probability about the parameter, requiring a prior distribution.

10

The "exact" Clopper-Pearson interval never drops below its stated coverage — but it overshoots, giving wider intervals than needed. Brown, Cai and DasGupta (2001) recommend Wilson, Agresti-Coull or Jeffreys instead.

Frequently Asked Questions

  • Technically: if you repeated your sampling procedure many times and computed a 95% CI each time, approximately 95% of those intervals would contain the true population parameter. The interval moves; the parameter is fixed. It does NOT mean "there's a 95% probability the parameter is in THIS specific interval" — that's a Bayesian interpretation requiring a prior. In practice, the strict interpretation is hard to internalise and most people use the looser interpretation. The looser interpretation is approximately correct for non-pathological priors, but the strict interpretation is what frequentist statistics actually claims.

  • For proportions at 95% CI: n ≈ (1.96/margin)² × p̂(1-p̂). Worst case is p̂ = 0.5, which maximises p̂(1-p̂) at 0.25. Rounding up to whole people: ±5% margin = n ≈ 385. ±3% = n ≈ 1,068. ±2% = n ≈ 2,401. ±1% = n ≈ 9,604. For means at 95% CI: n ≈ (1.96 × SD / margin)². The 1/√n scaling means halving the margin quadruples the required n — which is why a poll of 1,000 people, at about ±3.1%, is a common compromise between precision and cost.

  • Use t when you ESTIMATE the population SD from your sample (the usual case). Use z only when you KNOW the population SD exactly (rare). t is always wider than z, by more the smaller the sample: at 95%, t(4) = 2.776 against z = 1.960 for n = 5, about 4% wider at n = 31 and about 1.2% wider at n = 100. The "Use t-distribution" checkbox defaults to ON because it's the safer choice. Only use z if you have a textbook problem that explicitly says "assume σ = 10" or similar.

  • The Normal approximation p̂ ± z×√(p̂(1−p̂)/n) is mathematically simple but performs poorly when p̂ is near 0 or 1, or when n is small. The Wilson score interval (introduced by Wilson in 1927, popularised after 2001) uses a different derivation that constrains the interval to [0, 1] and has better coverage probability. For large samples (n > 100) and moderate proportions (0.2 < p̂ < 0.8), the two intervals are virtually identical. For small samples or extreme proportions, Wilson is significantly more accurate. Software is not consistent — some packages default to the normal interval — so when you compare with another tool, check which interval it reports.

  • Two-sided (the default) by far. Two-sided gives both upper and lower bounds, treating "too high" and "too low" symmetrically. One-sided gives only one bound and is useful in specific contexts (e.g. "minimum effective dose" trials only care about the lower bound; "maximum tolerable dose" trials only care about the upper bound). A one-sided 95% bound sits exactly where the matching end of a two-sided 90% interval sits — both use z = 1.645, as NIST's one-sided Wilson example does. Use two-sided unless you have a strong directional hypothesis stated before collecting data.

  • Direct, when the interval and the test come from the same method: a 95% CI excludes value X if and only if the two-tailed p-value for testing "parameter = X" is less than 0.05. A 99% CI excluding X = p < 0.01. So CIs and p-values carry the same information — but CIs are arguably more useful because they show: the estimate, the direction, the precision, AND statistical significance. The American Statistical Association's 2016 statement on p-values lists confidence intervals among the estimation methods statisticians use to supplement or even replace p-values.

  • Z and t intervals assume the sampling distribution of the mean is approximately normal. The Central Limit Theorem says the sampling distribution of the mean approaches normal as n grows, even for non-normal data; n > 30 is a rule of thumb for when that is close enough, not part of the theorem. For very heavily skewed data (income, response times), n > 100 might be needed. Below that, use: (1) bootstrap CI (sample with replacement, compute CI of the bootstrap distribution), (2) log-transform the data first, (3) non-parametric methods (Wilcoxon signed-rank CI). For most practical use cases with n > 30 and moderate skew, the z/t CI is accurate enough.

  • A frequentist confidence interval is a range computed from data that has a coverage property in repeated sampling (95% of intervals contain the truth, on average). A Bayesian credible interval IS a probability statement about the parameter: "given the data + prior, there's a 95% probability the parameter is in this interval." Credible intervals require specifying a prior distribution; CIs don't. For non-informative priors and large samples, the two intervals agree numerically but mean different things. Bayesian intervals are more intuitive but more controversial (the prior is subjective). This calculator computes frequentist CIs only.

  • No. All calculations run entirely in your browser via JavaScript. The calculation never goes to a server, and no request the page makes carries your inputs: DevTools → Network will still list the site's own page-view beacons and, if you have consented, analytics and ad requests, but none of them contains what you entered. Your sample data stays on your device. Safe for clinical trial CIs, proprietary survey results, A/B test conversion rates, or any inferential statistics work that shouldn't leave your machine.

  • Standard error of the mean = SD / √n. Standard error of a proportion = √(p̂(1−p̂)/n). Both scale with 1/√n — bigger n = smaller SE = tighter CI. The relationship is non-linear: doubling n only reduces SE by ~30% (√2 ≈ 1.41); quadrupling n cuts SE in half. This is why political polling sits at n=1000-2000 (±2-3% margin) — going larger gives diminishing returns. A ±0.1% margin at 95% would take about 960,000 responses — and a full census has no sampling error at all, which is why census counts are so much more precise than survey estimates.

Method & sources

How it computes

Mean: x̄ ± t(1 − α/2, n − 1) × s/√n, t computed exactly (or z when σ is known). Proportion: Wilson score interval, with the normal (Wald) p̂ ± z√(p̂(1 − p̂)/n) shown beside it unclipped and flagged when it leaves [0, 1] or there are fewer than 5 successes or failures. Levels 80, 90, 95, 99, 99.9%.

What this tool implements

  • NIST/SEMATECH e-Handbook §1.3.5.2: confidence limits for the mean are Ȳ ± t(1−α/2, N−1) · s/√N; the calculator reproduces NIST's worked example (N = 195, t = 1.9723, interval 9.258242 to 9.264679).
  • t critical values are computed by inverting Student's t through the regularised incomplete beta, and checked against every NIST §1.3.6.7.2 row the tests sample (df 1 to 100, the 0.90/0.95/0.975/0.995 columns).
  • NIST §7.2.4.1 gives the Wilson interval (Wilson 1927; recommended by Agresti & Coull 1998 and Brown, Cai & DasGupta 2001) and calls an interval whose limit is an impossible value "an inferior approach"; the normal interval is therefore shown unclipped and flagged rather than silently cut at 0 or 1. The calculator reproduces NIST's one-sided example (p̂ = 0.13, n = 200 → 0.09577).
  • Coverage figures on the page are computed exactly from the binomial, not quoted: at n = 30 and p = 0.10 a nominal 95% Wald interval covers 80.9% of the time and Wilson 97.4%.
  • Corrected 2026-10-25: "to halve the precision, quadruple the sample" (it halves the margin); t and z "virtually identical" for n > 30 (4.2% apart at n = 31) and "< 0.5%" apart at n = 100 (1.2%); 9/100 given as a Wald interval that goes negative (its lower limit is 3.4%; 2/100 goes to −0.74%); an unsourced "95% nominal might be 89% actual"; "modern statistical software defaults to Wilson"; the 2016 ASA statement "recommends preferring CIs" (it lists them among alternatives); "most journal style guides now require CIs"; "increasingly 99%" in medicine; the CLT "says" n > 30.

Sources

What can make this go out of date

  • None at runtime; the intervals are computed in the browser from the values entered.
Advertisement
Pre-footer · AD-W3 728 × 90