☰

Margin Of Error

Margin of Error: Definition, Formula and Worked Examples

A news channel says that 52 percent of voters back a party, with a margin of error of 3 points. Many viewers hear this as a small footnote. It is actually the most important part of the claim, because it tells you whether 52 is really ahead of 48 or only looks ahead.

Every survey and every A and B test works with a sample, not the whole population. The margin of error measures how far the sample result may sit from the truth because of chance alone. It is the number after the plus or minus sign, and it is the half width of a confidence interval.

This tutorial explains the definition, the formula, a worked example with the answer, how sample size and confidence level change the margin, how to find the sample size you need, and what a margin of error does not cover. It ends with Python code and practice questions.

What is the Margin of Error in Statistics?

The margin of error is the range of values above and below a sample estimate, within which the true population value is likely to lie. A result of 52 percent with a margin of error of 3 points gives an interval of 49 to 55 percent.

An interval estimate is a range of values built around a sample estimate. The live page calls it a pair of percentages, which is not accurate. The range can be in any unit, such as hours, rupees or percent.

Margin of error around a sample estimate

Probability and Non Probability Sampling

  • Probability sampling: every member of the population has a known chance of being selected. Random selection is the common form. Only this kind supports a real margin of error.
  • Non probability sampling: members are chosen for cost or convenience, such as an online poll that anyone can join. Some groups may be left out, so a margin of error from the formula does not hold.

The live page says researchers choose members so that the margin is as small as possible. In practice, you cannot shrink it by hand picking people. You reduce it with a bigger random sample.

Why do We Use the Margin of Error?

A sample result is a guess. Another sample would give a slightly different number. The margin of error shows how big that wobble is, so you can tell a real difference from noise.

  • Reading polls. If a lead is smaller than the margin, the race may be tied.
  • A and B tests. It shows how much to trust a measured lift.
  • Planning surveys. It tells you how many people you must ask.
  • Honest reporting. An estimate without a margin looks more certain than it is.

How is the Margin of Error Calculated?

For a mean, when the population standard deviation is known:

Margin of error = z times sigma divided by the square root of n
  • n = sample size.
  • sigma = population standard deviation.
  • z = the z score for your confidence level.

For a proportion, such as a poll percentage:

Margin of error = z times the square root of (p times (1 minus p) divided by n)

The live page stops at Margin of Error = z. That is not the formula.

Z scores for common confidence levels
Confidence level Z score Used when
90 percent 1.645 Quick checks
95 percent 1.960 The usual default
99 percent 2.576 High stakes, wider margin

Always state the level with the margin. A margin of 3 points at 95 percent and at 99 percent are different claims.

Margin of Error Formula with Examples

Margin of error formula with worked examples

Example 1: The Page Example, Completed

The live page gives n = 160,000, sigma = 8.47 and z = 2.58, and no answer.

  • Square root of n = square root of 160,000 = 400.
  • Standard error = 8.47 divided by 400 = 0.0212.
  • Margin of error = 2.58 times 0.0212 = 0.0546.

Meaning: at a 99 percent level (2.58 is the rounded z, the exact value is 2.576), the sample mean is likely within 0.0546 of the true mean. The margin is tiny because the sample is huge.

Example 2: A Poll

A poll of 1,000 voters finds 52 percent support for a party. The numbers are made up for teaching.

  • Standard error = square root of (0.52 times 0.48 divided by 1000) = 0.0158.
  • Margin of error at 95 percent = 1.96 times 0.0158 = 0.031, or about 3.1 points.
  • Interval = 48.9 to 55.1 percent.

The interval includes 50 percent, so this poll cannot say that the party is truly ahead of the rest. A lead of 2 points is smaller than the margin.

How the Sample Size Changes the Margin?

Margin of error at different sample sizes
Sample size Margin at 95 percent Compared with n = 100
100 9.8 points Base
400 4.9 points Half
1,000 3.1 points About a third
2,400 2.0 points About a fifth
10,000 0.98 points About a tenth

These use the worst case, p = 0.5. Four times the data halves the margin, because of the square root of n. This is why polls stop near 1,000 to 2,500 people: the gain from going further is small compared with the cost.

How the Result Itself Changes the Margin?

With n = 1,000, a result near 50 percent has a margin of 3.1 points. A result of 30 percent has 2.84 points, and 10 percent has 1.86 points. Results near 0 or 100 percent are more certain.

How Many People Do You Need? Sample Size for a Target Margin

Rearrange the formula. For a proportion at 95 percent, using p = 0.5 when you do not know the result:

n = z squared times p times (1 minus p) divided by (margin squared)
Sample size needed for a target margin
Target margin Sample size needed Note
5 points 385 Rough surveys
3 points 1,068 Common for polls
2 points 2,401 Better precision
1 point 9,604 Costly

What the Margin of Error Does Not Cover?

  • Bad sampling. If the sample is not random, the margin does not apply.
  • Non response. If one group refuses to answer, the result is biased.
  • Poor questions. Leading wording shifts answers, and no margin captures it.
  • Subgroups. Results for a small subgroup, such as one age band, have a bigger margin than the whole poll.

The margin of error covers random sampling error only. The live page says that the true value is usually near the estimate but might be a bit higher or lower, and cites Statistics Solutions with no link. I kept the idea, and wrote it in my own words.

Margin of Error and Confidence Interval

They are two views of the same thing. The confidence interval is the estimate plus and minus the margin of error. For example, 52 percent with a margin of 3.1 points gives the interval 48.9 to 55.1 percent. If you know one, you know the other.

Calculate the Margin of Error in Python

I ran the code below, and the output is real.

python
import math
from scipy import stats

# Page example: n 160000, sigma 8.47, z 2.58 (99 percent)
m = 2.58 * 8.47 / math.sqrt(160000)
print("Page example margin:", round(m, 4))
print("Exact z for 99 percent:", round(float(stats.norm.ppf(0.995)), 3))

# Poll margin of error at 95 percent, worst case p = 0.5
for n in (100, 400, 1000, 2400, 10000):
    print("n", n, " margin:", round(100 * 1.96 * math.sqrt(0.25 / n), 2), "points")

# Sample size needed for a target margin, 95 percent, p = 0.5
for e in (0.05, 0.03, 0.02, 0.01):
    print("Margin", e, " n needed:", math.ceil(1.96 ** 2 * 0.25 / e ** 2))

# Effect of p on the margin, n = 1000
for p in (0.1, 0.3, 0.5):
    print("p", p, " margin:", round(100 * 1.96 * math.sqrt(p * (1 - p) / 1000), 2), "points")
output
Page example margin: 0.0546
Exact z for 99 percent: 2.576
n 100  margin: 9.8 points
n 400  margin: 4.9 points
n 1000  margin: 3.1 points
n 2400  margin: 2.0 points
n 10000  margin: 0.98 points
Margin 0.05  n needed: 385
Margin 0.03  n needed: 1068
Margin 0.02  n needed: 2401
Margin 0.01  n needed: 9604
p 0.1  margin: 1.86 points
p 0.3  margin: 2.84 points
p 0.5  margin: 3.1 points

Common Mistakes to Avoid

Common mistakes and fixes
Mistake Fix
Giving a margin without a confidence level State the level, usually 95 percent
Using the formula for a non random sample The margin only holds for probability samples
Assuming a lead bigger than the margin is certain Compare the gap with about twice the margin for two candidates
Forgetting that the margin shrinks slowly with n Four times the sample halves the margin
Using the full poll margin for a subgroup A subgroup has a larger margin
Using the rounded z without saying so State the level, such as 95 percent with z 1.96
Believing the margin covers all errors It covers random sampling error only

Practice Questions

  1. n = 100, sigma = 5, 95 percent level. Find the margin of error.
  2. A poll of 400 people shows 50 percent. Find the 95 percent margin in points.
  3. How many people do you need for a margin of 5 points at 95 percent?
  4. A poll has a margin of 3 points. Party A has 51 percent and Party B has 49 percent. Is A clearly ahead?

Answers: 1) 1.96 times 5 divided by 10 = 0.98. 2) 1.96 times the square root of (0.25 divided by 400) = 0.049, so 4.9 points. 3) 385. 4) No. The intervals overlap, so the race may be tied. These are my own answers, so please recheck them before publishing.

The margin of error is the honest half of any survey result. Always show it with the confidence level, use a random sample so it means something, and remember that it shrinks only with the square root of the sample size. A small gap between two numbers is often just noise.

Popular Tags:

how is margin of error calculated margin of error definition margin of error example margin of error formula margin of error statistics margin of error tutorial what is margin of error in statistics