# Flipping fair coin -

Examining an event. Let's say we flip a fair coin many times. Let's say 1.000.000 times. We know that even though each flip is not connected, influenced by past or future flips, in the long run each side heads or tails will end up approximately around 500.000 (50/50 event - theory of equilibrium)

My question is: What price ranges can the difference take between heads and tails throughout the 1.000.000 flips? For example, if we could see the results at 1892 flips we may have witnessed a "70" difference (981 Heads over 911 Tails).

Or maybe if we could see the results at 15250 flips we may have witnessed a "6" difference (7622 Heads over 7628 Tails)

So... What could be considered a normal difference range? $\pm 70$? $\pm50$? And what could be considered an EXTREME RARE difference range somewhere in the flips? $\pm500$ $\pm2000$? $\pm10.000$?

-
You may proceed a statistical test to check if this coin is fair or not. Basically, using Central limit theorem. – echzhen Feb 25 at 0:22

Given a fair coin, the number of heads (in $1000000$ flips) has a binomial distribution with a mean of $500000$, but it is very close to being normally distributed with that same mean, and with a standard deviation of

$$\sigma = \sqrt{1000000 \left(\frac{1}{2}\right) \left(\frac{1}{2}\right)} = 500$$

Using the usual properties of the normal distribution, we find that the number of heads should be within $500$ (one sigma) of $500000$ about $68$ percent of the time, within $1000$ (two sigmas) about $95$ percent of the time, and so on.

ETA: (Semi-)fun fact—The probability that we are outside one sigma is approximately $\frac{1}{\pi}$; the probability that we are outside two sigmas is about $\frac{1}{7\pi}$; the probability that we are outside three sigmas is about $\frac{1}{16e^\pi}$.

-
so... seing a difference more than 1000 after the 10^6 spins is pretty rare(5%). or even difference above 2000 is (i guess )less than 1% in general using the type for σ we can calculate the deviation at any amount of flips and anything bigger than 2σ is rare? – Friday13 Feb 25 at 0:25
@Friday13 Not quite. Keep in mind that the head-to-tail difference is twice the difference from $500000$: If the number of heads is $500$ "high"—that is, $500500$—the number of tails is $499500$, or $1000$ lower than the number of heads. You should see a difference at least that large about $32$ percent of the time. – Brian Tung Feb 25 at 0:30
@Friday13 You should see a difference of at least $2000$ (two sigmas) about $5$ percent of the time; a difference of at least $3000$ (three sigmas) only about $0.3$ percent of the time. – Brian Tung Feb 25 at 0:31
yes. i see what you mean. i only calculated the half way until the 500.000 average. but there is 500 more difference to reach the 1000 difference total in between heads and tails. – Friday13 Feb 25 at 0:33

This is given by the standard deviation $\sigma$. In the case of a coin flipped N times, if we want to know the number of heads, the standard deviation, from the average of $N/2$ is $\sigma = \sqrt{.25N} = \sqrt{N}/2$.

Within 2 standard deviations is considered normal. Anything more than 2 standard deviations from the mean is usually considered an outlier.

-
or even three! there is 3 $-\sigma$ rejection rule. – Seyhmus Güngören Feb 25 at 0:20

Over many coin flips, the number of "Heads" is approximately normally distributed. (See: normal approximation to binomial.)

For $n$ coin flips, the distribution of the proportion of heads is approximately:

$$N\left(\frac{1}{2}n,\sqrt{\frac{1}{4}n}\right)$$

Construction a $95\%$ probability interval for this distribution, we can say that 95% of the time, the number of heads in $n$ coin flips will be within:

$$\left(\frac{n}{2}-(1.96)*\sqrt{\frac{1}{4}n},\frac{n}{2}+(1.96)*\sqrt{\frac{1}{4}n}\right)$$

For $n=1000000$ this implies that $95%$ of the time, the number of heads will be within the interval $$\left(499500,500500\right)$$

-

Note: This situation deserves some additional considerations which put the problem in a different light.

The following is from chapter III: Fluctuations in Coin Tossing and Random Walks of the classic An Introduction to Probability Theory and Its Applications, Vol. I by W. Feller.

(W. Feller): For example, in various applications it is assumed that observations on an individual coin-tossing game during a long time interval will yield the same statistical characteristics as the observation of the results of a huge number of independent games at one given instant. This is not so.

He continues with

According to widespread beliefs a so-called law of averages should ensure that in a long coin-tossing game each player will be on the winning side for about half the time, and the lead will pass not infrequently from one player to the other.

But, in fact this is wrong and contrary to the usual belief the following holds:

With probability $\frac{1}{2}$ no equalization occurred in the second half of the game regardless of the length of the game. Furthermore, the probabilities near the end point are greatest.

The reasoning is based upon the Arc sine law for last visits (see e.g. Vol 1, ch.3, section 4, Theorem 1): The probability that up to and including epoch $2n$ the last visit to the origin occurs at epoch $2k$ is given by \begin{align*} \alpha_{2k,2n}=\frac{1}{4^n}\binom{2k}{k}\binom{2n-2k}{n-k} \end{align*}

Since according to Stirling's formula \begin{align*} \binom{2k}{k}\sim \frac{1}{\sqrt{\pi k}} \end{align*} it can be shown that for fixed $0<x<1$ and $n$ sufficiently large \begin{align*} \sum_{k<xn}\alpha_{2k,2n}\approx \frac{2}{\pi}\arcsin \sqrt{x} \end{align*}

A consequence of the Arc since law are the following examples

Suppose that a great many coin-tossing games are conducted simultaneously at the rate of one per second, day and night, for a whole year.

• On the average, in one out of ten games the last equalization will occur before $9$ days have passed, and the lead will not change during the following 356 days.

• In one out of twenty cases the last equalization takes place within $2\frac{1}{2}$ days,

• and in one out of a hundred cases it occurs within the first $2$ hours and $10$ minutes.

(W. Feller): Anyhow, it stands to reason that if even the simple coin-tossing game leads to paradoxical results that contradict our intuition, the latter cannot serve as a reliable guide in more complicated situations.

-
Have anyone compiled statistics of the time of last equalization for human generated "random" sequences? I know the length of the longest run can be used to diffentiate human-produced "randomness" from "true randomness" but arsine law - because of it's large scale, rather than local dependence, could be better and harder to "trick". – A.S. Feb 28 at 19:14
@A.S.: Sorry, I'm not aware of any statistics of this kind. But regarding human generated "random" sequences, Flajolet in his classic "Analytic Combinatorics" tells us a nice litte story about T. Varga pointing to this article by P Revesz. – Markus Scheuer Feb 28 at 19:26