Rr‑statistics.co

Confidence Interval Calculator

A confidence interval gives a range of plausible values for what is really true in the population, not just a single point estimate. Pick a flavor (mean, proportion, difference, correlation, regression coefficient, Poisson rate, variance), drop in your stats, and get the interval, half-width, and reproducible R for every method.

i New to confidence intervals? Read the 4-min primer

What it is. You measure something on a small sample (50 customers, 30 patients, a handful of widgets) and you want to know what's true for the whole population. A confidence interval gives you a range of plausible values for that truth - not a single guess.

How to read it. A 95% CI of (67.9, 76.1) means: if we collected fresh samples like this 100 times and computed a CI each time, about 95 of those intervals would contain the truth. It does not mean "the truth is in this interval with 95% probability" - that's a Bayesian credible interval, a different framework.

The recipe. Most CIs are estimate ± multiplier × SE. Estimate comes from your sample; multiplier comes from a probability table (≈ 1.96 for 95% under normal); SE shrinks as your sample grows. A few flavors (Wilson, Clopper-Pearson, exact Poisson) use exact methods that always behave well at the boundaries.

Picking the flavor. Numeric values from a sample → use a CI for the mean. Yes/no rates → CI for a proportion. Two groups compared → CI for a difference. Pick the matching flavor in the sentence below.

8 flavors · one tool · Wilson · Clopper-Pearson · Newcombe · Welch · exact Poisson · Runs in your browser

Try a real-world example to load.

📐 Mean test score

A class of 30 students took a test; mean = 72, SD = 11. We want a 95% CI for the true class-level mean.

Pick a flavor and enter inputs.
R code RUNNABLE
R Reproduce in R

        
Confidence interval INTERACTIVE
Inference

Read more Anatomy of a confidence interval
Live recap - your inputs plugged in
Enter inputs above to see the derivation chain.
CI = estimate ± critical · SE
The general form. Most CIs decompose into a point estimate, a critical value from a sampling distribution (z, t, χ², F), and a standard error. The critical value depends on confidence level and (for some flavors) df; the SE depends on the data.
INα from your Confidence level (α = 1 − conf), critical from the appropriate distribution, SE from the formula below.OUTLower/upper bounds shown in the big CI display; half-width shown as the "± margin of error" in the result panel.
SE_mean = s / √n df = n − 1 critical = t_{1−α/2, df} CI = x̄ ± critical · SE
Mean (one sample). If you don't know σ - and you almost never do - use the t-distribution. For n > 30 the t and z critical values are essentially identical.
INx̄ = your Sample mean x̄, s = your Sample SD s, n = your Sample size n.OUTSE and t-critical printed under "point = … · half-width = …"; CI bounds in the headline.
Welch: SE = √(s₁²/n₁ + s₂²/n₂) Pooled: sp² = ((n₁−1)s₁² + (n₂−1)s₂²)/(n₁+n₂−2) SE = sp · √(1/n₁ + 1/n₂) df_Welch ≈ Satterthwaite CI = (x̄₁ − x̄₂) ± t_{1−α/2, df} · SE Paired: d̄ ± t · sd/√n, df = n−1
Difference of means. Welch (default) doesn't assume equal variances and adjusts df. For paired data (same subject measured twice), it reduces to a one-sample t-CI on the within-pair differences.
INIndependent: Group 1 + Group 2 with the Use Welch toggle. Paired: Number of pairs n, Mean difference, SD of difference.OUTMean diff is the point shown; SE and df in the aux line below the bounds.
p̂ = x / n Wilson score CI: center = (p̂ + z²/(2n)) / (1 + z²/n) half = z · √(p̂(1−p̂)/n + z²/(4n²)) / (1 + z²/n) CI = center ± half
Wilson is the right default for proportions. Stays inside [0, 1], performs well when is near 0 or 1, and matches what prop.test(..., correct = FALSE) reports. Wald is the textbook formula and is misleading at extremes - we still show it, but boxed for comparison.
INx = Successes x, n = Trials n, z from your Confidence level.OUTWilson row in the "All methods compared" table is the highlighted recommended one.
Clopper-Pearson exact: lower = qbeta(α/2, x, n−x+1) upper = qbeta(1−α/2, x+1, n−x)
Clopper-Pearson is the exact CI for a proportion via the binomial distribution. Always covers at least the nominal level (sometimes more) - conservative but never anti-conservative. Use when guaranteed coverage matters (regulatory, medical).
INSame Successes x and Trials n; α = 1 − conf level.OUTSecond row of the methods table.
Newcombe (independent): w₁ = Wilson(x₁, n₁); w₂ = Wilson(x₂, n₂) lo = (p̂₁ − p̂₂) − √((p̂₁−w₁_lo)² + (w₂_hi−p̂₂)²) hi = (p̂₁ − p̂₂) + √((w₁_hi−p̂₁)² + (p̂₂−w₂_lo)²) McNemar (paired): p̂_diff = (b − c) / n SE = √((b+c) − (b−c)²/n) / n CI = p̂_diff ± z · SE
Difference of proportions. For independent groups, Newcombe's score CI stays in [-1, 1]. For paired (same subjects under two conditions), use the McNemar-style discordant-pair formula.
INIndependent: Group 1 x₁, n₁ + Group 2 x₂, n₂. Paired: b (yes-no) + c (no-yes).OUTRecommended row of the methods table; for paired, also the McNemar χ² and p-value in the summary.
CI = β̂ ± t_{1−α/2, df} · SE(β̂)
Regression coefficient. Same skeleton, but the SE comes from the model's variance-covariance matrix and df is the residual df. confint() in R does exactly this for an lm fit.
INβ̂ = Estimate β̂, SE = Standard error SE(β̂), df = Residual df.OUTIf 0 lies outside [lo, hi], the coefficient is "significant" at α; the summary states this in plain English.
Exact (Garwood / χ² inversion): λ̂ = x / T lower = qchisq(α/2, 2x) / (2T) upper = qchisq(1−α/2, 2(x+1)) / (2T)
Poisson rate. The exact CI inverts the χ² distribution and works at any count, including x = 0. Wald (= λ̂ ± z·√x/T) is fine only for large x.
INx = Event count x, T = Exposure (person-time) T.OUTExact row (highlighted) in the methods table; λ̂ is the point estimate displayed.
CI for σ²: [(n−1)s² / χ²_{1−α/2, n−1}, (n−1)s² / χ²_{α/2, n−1}] CI for σ = √CI for σ²
Variance / SD. Built on the χ² distribution; assumes underlying normality. Highly sensitive to that assumption - a single outlier can dominate s². Don't trust this CI if a Q-Q plot looks bad.
INn = Sample size n, s = Sample SD s.OUTTwo rows: σ² and σ in the methods table; the SD row is highlighted as the more interpretable one.
Fisher z-transform: z_r = atanh(r), SE_z = 1/√(n−3) CI_z = z_r ± z_{1−α/2} · SE_z CI_ρ = tanh(CI_z)
Correlation. r's sampling distribution is skewed near ±1, so we transform to Fisher's z (where it's roughly normal), build the CI there, then back-transform.
INr = Sample correlation r, n = Sample size n.OUTBounds (asymmetric on the r-scale) in the headline; Fisher z and SE_z appear in the aux line.
Caveats When this is the wrong tool
If you have…
Use instead
Bootstrap CIs from raw data
R: boot::boot.ci() with type = "bca" - coming as a separate tool in Batch 8.
Bayesian credible interval
Different paradigm; we don't include here. Try a brms tutorial.
CI for ratio of means / variances
Fieller's theorem (means) or F-based (variances) - coming in Batch 6.
Survival times - Kaplan-Meier confidence band
Survival analysis tool - out of scope here.
Median CI
Order-statistic-based; needs raw data. Add as a v2 paste-mode option.
Further reading

Numerical accuracy: distribution functions accurate to ~10⁻⁷ (Hart's algorithm for normal, Cornish-Fisher for t).