[Math Lair] Flipping a Coin

Math Lair Home > Topics > Flipping a Coin

It can be interesting to flip a coin many times and record the results. You can try this yourself, flipping a coin and recording the results. Alternately, if you're so inclined, you can write a computer program to simulate the flipping of a coin (see note at bottom of page).

I flipped a coin 50 times, and the results were as follows:


So far there are 27 heads and 23 tails. Let's try flipping the coin another 50 times:


Now there are 51 heads and 49 tails. Flip it another hundred times and we get:


Now heads is ahead by a little bit, 109 to 91. Flipping the coin another 800 times (to bring the total to 1,000), we get:


Now there are 502 heads and 498 tails.

There are a few things of interest here. The first relates to the law of large numbers, which describes the results of performing an experiment a large number of times. As the number of trials increases, the average of the results obtained will get closer and closer to the expected value. The probability of the coin landing heads is 0.5, or 50%; the probability of the coin landing heads is also 0.5, or 50% . However, it doesn't necessarily mean that the number of heads and tails will necessarily ever be equal; rather, the percentage of heads and the percentage of tails will approach 50%. After 50 flips and after 1,000 flips, heads was ahead by 4 each time; however, after 50 flips, 54% were heads, while after 1,000, 50.2% were heads.

You might find something else of interest if you were to perform a large number of trials of flipping a coin 1,000 times. In this case, you would find that the number of heads varies from trial to trial. For example, one trial might give a result of 490 heads, the next 503, and so forth. However, the distribution of the number of heads will be bell-curve shaped. The number of heads is distributed normally, with the peak of the curve at 500.

The third thing of interest deals with randomness. The above strings represent a random sequence of 1,000 heads and tails. Looking at the sequence, you might think that the sequence might not look random. For example, you might have noticed that the first 50 tosses contained a string of 11 heads in a row. There are also several clusters of 8 of the same side in a row, a string of 17 flips containing only 2 heads, and the pattern THT repeated five times in a row. However, these sorts of patterns will occur every once in a while in random sequences. If you were to create a create a "random" sequence, you might be tempted to create one something like the following:


However, this sequence is much less random than the above sequences. For example, a T is followed by an H much more often than another T. See clustering illusion for more discussion about randomness and clustering.

Note: Writing a computer program to simulate the flipping of a coin isn't too difficult; in a language such as perl, you can write a program to do this in one line:

@x = qw/H T/;for (1..number of throws){print $x[int(rand(2))]}
where number of throws is the number of throws to simulate (e.g. 100).