Skip to content
induwara.lk
induwara.lkStatistics · Research

Confidence Interval Calculator

Find the confidence interval and margin of error for a sample mean or a proportion at any confidence level. It picks the right method automatically, z, Student's t, or the Wilson score interval, and shows every step so you can cite it. No signup, sources below.

By Induwara AshinsanaUpdated Jun 11, 2026
Confidence intervalmean or proportion
NIST formulas · cross-checked

Average of your sample.

s (sample) or σ (population).

Number of observations (≥ 2).

How was the standard deviation obtained?
%

Pick a preset or type any level from 50% to 99.99%.

Method: t-interval, SD estimated from the sample, df = 24
Point estimate (x̄)
68
Margin of error
± 2.0639
Critical value (t)
2.0639
df = 24 · SE = 1
Confidence interval
[65.9361, 70.0639]

We are 95% confident the true population mean lies between 65.9361 and 70.0639.

Show working

  1. SE = s / √n = 1
  2. t = T⁻¹(0.975, df=24) = 2.0639
  3. ME = t · SE = 2.063899
  4. interval = x̄ ± ME = [65.936101, 70.063899]

Cross-check: pushing t = 2.0639 back through the Student's t CDF recovers a 95% confidence level, matching the input.

Sources cited

How it works

A confidence interval puts a plausible range around a sample estimate. For a chosen confidence level C, the two-tailed tail area is α = 1 − C, split into α/2 in each tail. Every interval here has the same shape, point estimate ± (critical value × standard error), but the critical value and standard error change with the method, which the tool selects from your inputs.

Mean, population SD known (z-interval). When the population standard deviation σ is genuinely known, the standard error is SE = σ / √n and the critical value is the standard-normal quantile z = Φ⁻¹(1 − α/2) (1.96 at 95%). The interval is x̄ ± z·SE (NIST §1.3.5.2).

Mean, SD estimated (t-interval). When σ is estimated from the sample, the usual case, the standard error is SE = s / √n and the critical value is the Student's t quantile t = T⁻¹(1 − α/2, n − 1). This tool inverts the t distribution numerically through the regularized incomplete beta function, so any degrees of freedom resolve exactly rather than being read off a rounded table.

Proportion, Wilson score interval (default). With p̂ = x/n and z = Φ⁻¹(1 − α/2), the interval centres on (p̂ + z²/2n) / (1 + z²/n) with half-width [z/(1+z²/n)] · √(p̂(1−p̂)/n + z²/4n²), clamped to [0, 1] (Wilson 1927; NIST §8.4.1.3). Because it is asymmetric the tool shows both the Wilson centre and the sample p̂.

Proportion, Wald interval (optional). The simpler p̂ ± z·√(p̂(1−p̂)/n) is offered for comparison, with a warning: it under-covers and can leave [0, 1] when n is small or p̂ is near 0 or 1, which is exactly why Wilson is the default. As a built-in check, each critical value is pushed back through its own CDF to confirm it recovers the confidence level you asked for.

Worked examples

t-interval on a mean (SD estimated)

n = 25, x̄ = 68, s = 5, 95% confidence

  1. SE = s / √n = 5 / √25 = 5 / 5 = 1
  2. df = n − 1 = 24; t₀.₉₇₅,₂₄ = 2.0639
  3. ME = t × SE = 2.0639 × 1 = 2.0639
  4. Interval = 68 ± 2.0639 = [65.94, 70.06]
  5. Read: 95% confident the true mean is between 65.94 and 70.06.

Wilson interval on a proportion

x = 45, n = 60 (p̂ = 0.75), 95% confidence, z = 1.96

  1. z² = 3.8416; z²/n = 0.06403; z²/2n = 0.03201
  2. centre = (0.75 + 0.03201) / (1 + 0.06403) = 0.73496
  3. root = √(0.75·0.25/60 + 3.8416/(4·60²)) = √0.0033918 = 0.05824
  4. half-width = (1.96 / 1.06403) × 0.05824 = 0.10728
  5. Interval = 0.73496 ± 0.10728 = [0.6277, 0.8422] → [62.77%, 84.22%]
  6. Wald for contrast: 0.75 ± 0.1096 = [64.0%, 86.0%], narrower and skewed.

Edge case, zero successes (Wilson)

x = 0, n = 30 (p̂ = 0), 95% confidence

  1. p̂ = 0, so the usual Wald interval would collapse to [0, 0].
  2. Wilson centre = (0 + z²/60) / (1 + z²/30) = 0.05676
  3. half-width = (z/(1+z²/30)) · √(0 + z²/(4·30²)) = 0.05676
  4. Interval = 0.05676 ± 0.05676 = [0, 0.1135] → [0%, 11.35%]
  5. Wilson still gives a usable upper bound where Wald gives nothing.

Frequently asked questions

Sources & references

The z, t and Wilson formulas on this page were last cross-checked against the NIST e-Handbook on 2026-06-11. Critical values are computed numerically (Acklam's inverse-normal approximation for Φ⁻¹; incomplete-beta inversion for the t quantile), so any confidence level and degrees of freedom resolve exactly to the displayed precision.

Related tools

Comments & feedback

Spotted a bug or want an improvement? Tell us, our team reviews every comment, and good ideas get built. Comments are public and anonymous.

Found a bug, edge case, or want to suggest an improvement?

Email me at [email protected] , most fixes ship within 24 hours.