# Tricky probability explanation

Question:

How many times do we have to throw a normal coin so that, we are at least $99\%$ sure, that the percentage of heads will be between $49.5\%$ and $50.5\%$?

Solution:

\begin{align} 99\% \ \text{CI} &= p \pm 2.575 \cdot \sqrt{\frac{p(1-p)}{n}} \\ (0.495, 0.505) &= 0.5 \pm 2.575 \cdot \sqrt{\frac{0.25}{n}} \\ 0.005 &= 2.575 \cdot \frac{0.5}{\sqrt{n}} \\ n &= \left(2.575 \cdot \frac{0.5}{0.005}\right)^2 \\ &= 66306.25 \end{align}

then $66307$ tosses would be required.

Could you please explain the solution in a simple way? Or if it's possible to give an alternative solution?

-
 Your solution method is fine, so I don't know what you mean by a "simple way". – TMM Jun 3 '12 at 16:09 What is it you don't understand? This seems like a standard computation using the normal distribution – M Turgeon Jun 3 '12 at 16:09 Where does 2.575 come from??? – user32810 Jun 3 '12 at 16:11 @user32810 Probably from a table of values for the standard normal – M Turgeon Jun 3 '12 at 16:15 Is this table somewhere to be found??? – user32810 Jun 3 '12 at 16:33
show 1 more comment

## 2 Answers

Something that might help, is doing the computations in reverse order. Suppose $n$ is in fact known, and we want to calculate the $99\%$ two-sided confidence interval for the mean.

First, let $X$ be the number of heads in $n$ tosses. Then $X$ is binomially distributed, with $p = 0.5$ and $n = n$. For large values of $n$, we know we can approximate the binomial distribution with parameters $p$ and $n$ with a normal distribution with mean $np$ and variance $np(1-p)$. In this case this means the mean of $X$ is thus $0.5 n$, and the variance is $0.25 n$, so we can approximately say $X \sim \mathcal{N}(0.5 n, 0.25 n)$.

What we are interested in is the ratio of heads. If $Y$ is the fraction of heads, then $Y = X/n$, so $Y$ has mean $0.5$ and variance $\frac{1}{4n}$. Now $Z = \frac{Y - \mu}{\sigma} = \frac{Y - 0.5}{\sqrt{\frac{1}{4n}}}$ is standard normally distributed, with mean $0$ and variance $1$.

We want to make sure that the probability of getting a value of $Y$ between $0.495$ and $0.505$ is at least $0.99$. But we can calculate that probability:

\begin{align} P(0.495 < Y < 0.505) &= P\left(\frac{0.495 - 0.5}{\frac{1}{\sqrt{4n}}} < \frac{Y - 0.5}{\sqrt{\frac{1}{4n}}} < \frac{0.505 - 0.5}{\frac{1}{\sqrt{4n}}}\right) \\ &= P\left(-0.01 \sqrt{n} < Z < 0.01 \sqrt{n}\right) \\ &\geq 0.99.\end{align}

Since $Z$ is symmetric around $0$, the left and right excluded tails are the same. So

\begin{align} P\left(-0.01 \sqrt{n} < Z < 0.01 \sqrt{n}\right) &= 1 - P(Z < -0.01\sqrt{n}) - P(Z > 0.01\sqrt{n}) \\ &= 1 - 2 P(Z < -0.01\sqrt{n}) \\ &\geq 0.99. \end{align}

Doing a little algebra, we get

$$P(Z < -0.01\sqrt{n}) \leq 0.005$$

Looking up the $0.005$ in a standard normal table, we know that

$$P(Z < a) \leq 0.005 \quad \Leftrightarrow \quad a \leq -2.575$$

So this translates to a condition for $n$:

$$-0.01\sqrt{n} \leq -2.575 \quad \Leftrightarrow \quad \sqrt{n} \geq 257.5 \quad \Leftrightarrow \quad n \geq 66306.25.$$

-

A different approach: The two-sided $99\%$ confidence interval of a binomial distribution [link] is given by

$$\left(\hat{p} - z_{0.995} \sqrt{\frac{\hat{p}(1-\hat{p})}{n}}, \quad \hat{p} + z_{0.995} \sqrt{\frac{\hat{p}(1-\hat{p})}{n}}\right).$$

Here $z_{1-\alpha/2} = z_{0.995}$ is the $0.995$-percentile of the normal distribution, and $\hat{p}$ is the estimate for $p$. With $99\%$ certainty the fraction of heads will be in this interval. We want to make sure that with $99\%$ certainty the fraction of heads is actually in the interval $(0.495, 0.505)$, so we need that the above interval is contained in $(0.495, 0.505)$. After all, if $P(X \in A) \geq 0.99$ and $A \subseteq B$, then also $P(X \in B) \geq 0.99$. So this leads to the conditions

$$\hat{p} - z_{0.995} \sqrt{\frac{\hat{p}(1-\hat{p})}{n}} \geq 0.495, \quad \hat{p} + z_{0.995} \sqrt{\frac{\hat{p}(1-\hat{p})}{n}} \leq 0.505.$$

In your case, $\hat{p} = 0.5$, and since $P(Z \leq 2.575) = 0.995$ for standard normal random variables $Z$ we have $z_{0.995} = 2.575$. So the conditions become

$$0.5 - 2.575 \sqrt{\frac{0.5 (1-0.5)}{n}} \geq 0.495, \quad 0.5 + 2.575 \sqrt{\frac{0.5 (1-0.5)}{n}} \leq 0.505.$$

So in this case, these are in fact equivalent, and can be rewritten with some algebra as

$$n \geq \frac{0.5 \cdot 0.5 \cdot 2.575^2}{0.005^2} = 66306.25$$

-