Let $X_1, X_2, … $ be i.i.d. random variables with mean $\mu$, variance $\sigma^2 $.
let
$$M_n = \frac{ X_1, X_2, …, X_n }{ n }$$
$\forall \epsilon > 0 $, we have
$$\limu{ n }{ \infty } P(\abs{ M_n - \mu } \geq \epsilon) =0$$
or
$$ M_n \ipto \mu $$
</span>
</span>
<span class="proof__expand"><a>[expand]</a></span>
Suppose that the portion of people voting for the candidate $A$ is $p$. You select $n$ people in random. Let $M_n$ be the potion of people voting for $A$ among these $n$ people.
Suppose you want the confidence level of $95%$ with the mistake at most $\epsilon = 0.01$. How many voters should be sampled?
$$X_1, X_2, … X_n \text{~ Bernoulli}(p), M_n = \frac{ X_1, X_2, …, X_n }{ n }$$
Notice the fact that
$E[X_i] = p, \var{ X_i } = p(1-p), \forall i \in {1, …, n}$.
$$P(\abs{ M_n - p } \geq \epsilon) \leq \frac{ p(1-p)}{ n \epsilon^2 }$$
Assume that the true value of $p$ is unknown. We use the conservative bound of variance $\frac{(b - a)^2 }{ 4 } $ instead. We have $\var{ X_i } \leq \frac{(1 - 0)^2 }{ 4 } = \frac{ 1 }{ 4 } $.
$$P(\abs{ M_n - p } \geq \epsilon) \leq \frac{ 1 }{ 4 n \epsilon^n }$$
To achieve $95% $ confidence level at most $\epsilon = 0.01 $,
Not done yet
$ P(\abs{ M_n - p } \geq 0.01) \leq \frac{ 1 }{ 4 n \epsilon^2 } \leq 0.05 $
We have to ask $n \geq 50000$ people.