# How many times do I need to toss a coin

I have a homework question that's driving me crazy:

How many times do we need to toss a coin so that with prob. .9 the discrepancy of the relative frequency of appearance of heads from 1/2 is less than .02.

My initial thought was to somehow use a normal curve and solve for N, but I'm stuck and can't figure out what to do.

I guess I'm also having issue understanding the question itself.

Any thoughts? (Please don't solve the problem, I want to learn how to do it.)

-

We know that the standard error of an estimate of a proportion of a sample is $$\text{S.E} = \sqrt{\frac{p(1-p)}{n}}$$

where $n$ is the number of flips and $p$ is the estimated probability of heads (i.e. $1/2$).Take $p = 0.5$. Now look at $|p-r|$. So $|p-r| < \epsilon$ where $\epsilon = Z \cdot \text{S.E}$.

-
I'm sorry, could you explain what r is in |p-r|? – kodai Apr 14 '11 at 2:36
$r$ is the actual number of heads observed (e.g. 123 heads in 300 trials). – PEV Apr 14 '11 at 2:37
PEV Your comment seems spectacularly wrong: if r is the number of heads observed e.g. r=123 and p is the probability of a head i.e. p=1/2, then |p-r| is huge. – Did May 28 '11 at 16:54
@Didier Piau: $r = 123/300$. – PEV May 28 '11 at 17:53
PEV: Of course--but this not what you wrote. By the way, the last sentence of your post makes no sense either. – Did May 28 '11 at 18:01

To expand on Yuval's last indication, you observe the frequency $F_n$ of heads after $n$ tosses and you ask for $n$ such that $P(|F_n-.5|\ge.02)\le1-.9=.1$.

The normal approximation says that $\sqrt{n}(F_n-.5)$ behaves like $.5Z$, where $Z$ is a standard normal random variable. The multiple $.5$ here is the standard deviation of the result of a single toss. Thus the usual way to approach your problem is to look for $n$ such that $$P(.5|Z|\ge.02\sqrt{n})\le.1.$$ Now you must find somewhere the tabulated values of the probability distribution function of $Z$ and look for a value $z$ such that $P(|Z|\ge z)=.1$, or, equivalently, $P(Z\le z)=.95$, or, equivalently, $P(0\le Z\le z)=.45$.

Then you plug this $z$ into your approximation, getting $.02\sqrt{n}\approx.5z$, that is $n\approx625z^2$. Since $z\approx1.645$, $n\approx1690$.

-

If you want to get an exact answer you'll have to calculate some binomial sums. The probability that the discrepancy be at most $.02$ is equal to some sum of binomial terms, which the computer will happy compute for you exactly.

If you do that, you'll find that all $n \geq 1724$ work, but there are some sporadic values before that, the smallest one being $n = 1650$. This sort of behavior can't happen under the normal approximation.

Of course, for your numbers the normal approximation is pretty good - do the calculation and see how close you get to the "real" results.

-
Yuval: presumably the sporadic values are due to 'edge effects' with respect to where a discrepancy of .02 lies with respect to the precice number of samples? – Steven Stadnicki May 29 '11 at 16:41
Presumably. Using a normal approximation, everything is continuous so this can't happen. – Yuval Filmus May 29 '11 at 17:23