Margin of Error Calculator

Find the margin of error for a survey or poll result. Enter your sample size and proportion below, and see the formula, a worked example, and ready-to-use Python code underneath.

Enter your values

Not sure of the proportion? Leave it at 50% — that gives the largest, most conservative margin of error for your sample size.

Please enter a sample size of at least 1 and a proportion between 0 and 100.

Margin of error
Critical value (z)
Confidence interval

What margin of error tells you

Margin of error describes how much a survey's reported percentage might differ from the true value in the full population, due to sampling variability. A poll of 1,000 people reporting "52% support, ±3 percentage points" is really saying the true support is estimated to fall somewhere between 49% and 55%, at whatever confidence level was used.

Margin of error shrinks as the sample size grows, and grows as you demand a higher confidence level — there's an inherent trade-off between sample size, confidence, and precision.

Margin of error formula

MOE = z · √( p(1 − p) / n )
p is the sample proportion (as a decimal), n is the sample size, and z is the critical value for the chosen confidence level (1.645 for 90%, 1.96 for 95%, 2.576 for 99%).

Python code

You can compute the margin of error manually, or with statsmodels:

# Method 1 — manual calculation
import math
n = 1000
p = 0.52
z = 1.96  # 95% confidence
moe = z * math.sqrt(p * (1 - p) / n)
print(moe)  # 0.0310 (about ±3.1 percentage points)

# Method 2 — statsmodels (also gives the full interval)
from statsmodels.stats.proportion import proportion_confint
lower, upper = proportion_confint(count=520, nobs=1000, alpha=0.05, method='normal')

Worked example

A poll of 1,000 randomly selected voters finds that 52% support a candidate. Find the margin of error at 95% confidence.

  1. 1
    Identify the critical value.
    For 95% confidence, z = 1.96
  2. 2
    Compute the standard error.
    √(0.52 × 0.48 / 1000) = √0.0002496 = 0.0158
  3. 3
    Multiply by the critical value.
    MOE = 1.96 × 0.0158 = 0.0310, or about 3.1 percentage points

The poll's result is 52% ± 3.1% — we're 95% confident the true level of support is between about 48.9% and 55.1%.

Frequently asked questions

What does "margin of error" mean in a poll?

It's the half-width of the confidence interval around a survey result. A poll reporting 52% support with a margin of error of ±3% means the true population support is estimated to fall between about 49% and 55%, at the stated confidence level.

Why does this calculator default to 50% if I don't know the proportion?

The margin of error is largest when the true proportion is near 50%, so using 50% when the actual proportion is unknown gives the most conservative (largest, safest) margin of error estimate for a given sample size.

How does sample size affect the margin of error?

Margin of error shrinks as sample size grows, but not proportionally — it's divided by the square root of n. Quadrupling the sample size only halves the margin of error, which is why going from a very small to a merely small sample helps a lot, but going from a large sample to a much larger one yields diminishing returns.

Does this margin of error account for a finite population?

No — this calculator assumes the population is effectively infinite (or very large relative to the sample), which is the standard assumption for national or large-scale surveys. For a small, known population, a finite population correction would reduce the margin of error slightly; see the Sample Size Calculator for a version handling this.

What's the difference between margin of error and a confidence interval?

The margin of error is the half-width, or radius, of the confidence interval — it's a single number describing how far the interval extends in each direction from the sample estimate. The confidence interval itself is the full range, from the estimate minus the margin of error to the estimate plus it.

Advertisement