Confidence Interval and Margin of Error Calculator

A sample gives an estimate, never the exact population value. This calculator turns that estimate into a range: a confidence interval for a mean or a proportion, with its margin of error, the critical value behind it, and, in the planning modes, the sample size needed before you collect any data to hit a target margin.

How to use this calculator

  1. Pick the job: an interval for a mean, an interval for a proportion, or one of the two planning modes that work out the required sample size before data collection.
  2. Set the confidence level. 95% is the usual default; 99% widens the interval (or grows the sample size) and 90% narrows it. The custom option accepts any level from 50% to 99.9%.
  3. For a mean: enter the sample mean, the standard deviation and n. Choose the t method when the SD comes from your sample (the usual case), or z when the population SD is genuinely known. Add the population size only when your sample is a noticeable share of a small population; the design effect only for clustered or weighted survey designs.
  4. For a proportion: enter the proportion directly or as a count of successes out of n. Wilson is the recommended method; Wald is the classic textbook form, shown for comparison and teaching.
  5. Press Calculate and read the interval first, then the margin and the critical value that produced them.

The method

Means: estimate ± critical value × standard error

Interval = x̄ ± c × (s / √n),  margin of error = c × (s / √n)

The critical value c comes from the t distribution with n − 1 degrees of freedom when the SD is a sample SD, which widens the interval honestly for small samples, or from the normal distribution (z) when the population SD is known: 1.645 at 90%, 1.96 at 95% and 2.576 at 99%. Both are computed here exactly, not read from a printed table.

Proportions: Wald and Wilson

Wald: p̂ ± z × √(p̂(1 − p̂) / n)

The Wald interval is simple and symmetric, which is why textbooks teach it, but it misbehaves for small samples or proportions near 0 or 1: it can dip below 0 or above 1 and its true coverage can fall well below the stated level. The Wilson score interval recentres the estimate slightly towards 0.5 and is asymmetric; it stays inside [0, 1] and holds its coverage far better, which is why it is the default here.

Small populations: the finite population correction

When the sample is a substantial share of a finite population (rule of thumb: more than about 5%), the standard error is multiplied by √((N − n)/(N − 1)), the finite population correction. Sampling a large share of everyone leaves less unknown, so the interval narrows. Leave the population blank whenever the population is large or the sampling fraction is tiny; the correction is then negligible.

Planning a sample size

Mean: n = (z × s / E)²    Proportion: n = z² × p(1 − p) / E²

Solve the margin formula for n, with E your target margin. The result is always rounded up: rounding down would leave the margin slightly larger than the target. A design effect multiplies the requirement (clustered designs carry less information per person), and a known finite population reduces it through the adjustment n / (1 + (n − 1)/N), applied before rounding up. Planning uses z values, since the sample SD is not known yet; with a small planned n the achieved t-based margin will be a shade wider, which the limitations section flags.

Worked examples

Example 1: a mean with the t method

A sample of 25 measurements has mean 50 and sample SD 10. The t critical value with 24 degrees of freedom at 95% is 2.06, the standard error is 10/√25 = 2.00, so the margin is 2.06 × 2.00 = 4.13 and the interval is 45.87 to 54.13. This is the preloaded case. Using z instead would give a margin of 3.92 and a slightly narrower interval that pretends the SD is known exactly.

Example 2: a proportion, Wald versus Wilson

60 of 100 respondents agree (p̂ = 0.60). The Wald margin is 1.96 × √(0.6 × 0.4/100) = 0.0960, giving 0.5040 to 0.6960. The Wilson interval for the same data is 0.5020 to 0.6906: similar here, because n = 100 and the proportion is central, but pulled slightly towards 0.5. With 6 of 10 instead, the two methods diverge visibly, and Wilson is the one to trust.

Example 3: planning a survey

For a margin of ±3 percentage points at 95% with no prior idea of the proportion (p = 0.5, the safest choice), n = 1.96² × 0.25 / 0.03² = 1,067.07, rounded up to 1,068 responses. This is the famous “about a thousand” behind most national polls. Planning for a mean with SD 10 and a target margin of 2 needs (1.96 × 10/2)² = 96.04, rounded up to 97.

Reading your results

The interval is the headline: the range of population values consistent with your sample at the stated level. The margin of error is the half-width for symmetric intervals: the estimate plus or minus the margin is the interval. The critical value shows what your confidence level cost: pushing from 95% to 99% trades a wider interval for a stronger claim. The standard error is the engine underneath: it shrinks with the square root of n, which is why quadrupling the sample only halves the margin.

For proportions, results are shown both as decimals and as percentages. The Wilson interval has no single margin, because it is not symmetric around the sample proportion; the calculator says so rather than inventing one.

In planning modes the headline is the required n, already rounded up, with the unrounded figure shown so the rounding is transparent. Any design effect or population adjustment applied is stated on its own line.

Common mistakes

  • Reading 95% as “95% chance the truth is in this interval”. Once computed, the interval either contains the population value or it does not. The 95% describes the method: in the long run, 95% of intervals built this way capture the truth. The distinction matters when results get quoted.
  • Believing the margin of error covers every error. It covers random sampling error only. A biased sample, leading questions and low response rates introduce errors the margin says nothing about, and they do not shrink with n.
  • Using z with a small sample SD. With n = 12 and an SD from the sample, z understates the uncertainty. The t method exists precisely for this; the difference fades as n grows past roughly 30 to 50.
  • Planning with an optimistic proportion. Using p = 0.2 in the sample size formula because you hope the result lands there under-sizes the study if the true value is nearer 0.5, where the variance is largest. That is why 0.5 is the default.
  • Rounding a required sample size down. 1,067.07 needs 1,068 people. Rounding to 1,067 quietly misses the target margin.
  • Asking why a bigger population does not need a bigger sample. Precision depends on the sample size, not the population size, until the sample becomes a real share of the population. A sample of 1,068 measures a city of 100,000 and a country of 100 million equally well.

Limitations

  • Intervals assume a random sample from the population of interest and independent observations. Convenience samples, voluntary response panels and clustered data analysed as if simple random all produce intervals that look right and are not.
  • The mean interval assumes the data are roughly normally distributed, or n large enough for the central limit theorem to cover the mean. Heavily skewed data with small n needs other methods.
  • Planning figures use z values and your assumed SD or proportion; if the real SD is larger than assumed, the achieved margin will be wider than the target. Pilot data or a conservative SD protects against this.
  • The design effect is a single multiplier you supply; the calculator does not estimate it from a design. The finite population correction assumes simple random sampling without replacement.

Frequently asked questions

What is the margin of error?

The half-width of a symmetric confidence interval: how far the sample estimate could plausibly be from the population value because of random sampling alone. A result reported as 60% ± 4 points means the interval runs from 56% to 64%.

What does a 95% confidence level actually mean?

That the method captures the true population value in about 95% of samples. It is a property of the procedure over many samples, not a probability attached to the one interval in front of you, and it says nothing about bias in how the sample was drawn.

Should I use z or t for a mean?

t whenever the standard deviation comes from your sample, which is almost always. z is correct when the population SD is known from outside the sample, and is the large-sample limit of t. This calculator offers both and labels them plainly.

Why does the sample size formula use p = 0.5 by default?

Because p(1 − p) is largest at p = 0.5, so planning with 0.5 guarantees the target margin whatever the true proportion turns out to be. If a pilot or prior study pins the proportion near 0.2, entering 0.2 legitimately reduces the required n.

How many responses do I need for a ±5% margin?

At 95% with p = 0.5: 1.96² × 0.25 / 0.05² = 384.16, so 385 responses. Try it in the planning mode: the same formula gives 1,068 for ±3% and 97 for a mean with SD 10 and margin 2.

Why is the Wilson interval not centred on my proportion?

It blends the sample proportion with 0.5 by an amount that fades as n grows, which corrects the Wald interval’s poor behaviour for small samples and extreme proportions. The slight shift is the price of coverage that matches the stated level.

Related calculators

Method: mean intervals as estimate plus or minus a t (n − 1 degrees of freedom) or z critical value times the standard error; proportion intervals by the Wald formula or the Wilson score formula; finite population correction and design effect applied as documented; sample sizes solved from the margin formulas and rounded up. Critical values computed from the exact normal and t distributions and checked against standard statistical software values (z 1.96 at 95%, t 2.06 at 24 degrees of freedom). Last reviewed: 21 October 2026.

Disclaimer: This calculator gives estimates for general information only. It is not financial, medical or other professional advice.