# Margin of Error

How to find the margin of error from the sample proportion: definition, formula, 1 example, and its solution.

## Sample Proportion

### Definition

In reality,
we don't know the p (proportion)
of the whole data (population).

So, to find the p,
we pick a sample
and find the proportion of the sample:
p^.

p^ is read as [p hat].

## Formula

### Formula

But p^ and p cannot be always the same.
The sample cannot always represent
the whole population.

Then people found out that,
under a certain confidence level,
p is in this interval.

p^ - Z√[p^⋅q^]/n ≤ p ≤ p^ + Z√[p^⋅q^]/n

Shortly, p is in
p^ ± Z√[p^⋅q^]/n.

This Z√[p^⋅q^]/n
is the margin of error.

Z: Z-score (related to the confidence level)
p^: Probability (proportion) of the wanted event
q^ = 1 - p^
n: Number of the values of the sample

As you can see,
if n (sample number) increases,
the margin of error decreases.

So we can determine p (population proportion)
more precisely.

But if n increases,
you need more resources (time, money)
to find p.

So it's good to find the right n.

## Example

### Solution

It says
in a random sample,
64% of the people favored the candidate A.

So the sample proportion is
p^ = 0.64.

p^ = 0.64

Then q^ = 1 - 0.64.

This q^ means
the sample proportion of the people
not favored the candidate A.

Probability: Not A

1 - 0.64 = 0.36.

The sample number is 256.

So n = 256.

p^ = 0.64
q^ = 0.36
n = 256

Then [p^⋅q^]/n = [0.64⋅0.36]/256.

Multiply 1002
to both of the numerator and the denominator.

Then [64⋅36]/[256⋅1002].

64 = 26
36 = 22⋅32

256 = 28

Prime Factorization

Cancel 26⋅22 in the numerator
and cancel the denominator 28.

32/1002 = [3/100]2

Power of a Quotient

3/100 = 0.03

Find the z-score.

It says
P(0 ≤ Z ≤ 1.96) = 0.4750.

Recall that
for the normal distribution curve,
the left side and the right side
are the same.

So P(-1.96 ≤ Z ≤ 1.96) = 0.4750⋅2 = 0.95.

P(-1.96 ≤ Z ≤ 1.96) = 0.95 means
the z-score for 95% is Z = 1.96.

So Z = 1.96.

Then the margin of error, ME,
is equal to,
the z-score, 1.96

times
square root, [p^⋅q^]/n, 0.032.

So the margin of error is
(ME) = 1.96⋅√0.032.

0.032 = 0.03

Square Root

1.96⋅0.03 = 0.0588

0.0588 = 5.88%

So the margin of error is 5.88%.

This means
for 95% probability,
the candidate A's favorability rating is
64% ± 5.88%:
58.12% ~ 69.88%.