Tuesday, 26 January 2010

An exceedingly regular coin

If I throw a fair coin (one that always lands on a face, never on its edge, and has equal probability of showing heads or tails) one hundred times, I know that it is not guaranteed to give exactly fifty heads and fifty tails, of course. However, exactly fifty heads and fifty tails (in any order) is certainly possible. What are the chances of it happening?

If the coin is thrown 2n times, then the number of distinct outcomes (each being a distinct sequence of 2n occurrences of heads or tails) is 2^2n (where ^ means power), because each occurrence has two possible states (heads or tails) and there are 2n such occurrences in total.

If an outcome (being a sequence of 2n occurrences of heads or tails) comprises h heads and t tails, with h+t=2n, then the number of such outcomes is (2n)!/(h!t!), because the number of ways of arranging 2n occurrences is 2n! but each such result comprises h occurrences of heads, which can be arranged in h! ways, and t occurrences of tails, which can be arranged in t! ways, so we have counted each distinct result h!t! times. If we are looking for cases where h=n and t=n, then the number of such outcomes is (2n)!/(n!n!), or (2n!)/(n!)^2.

So, the proportion of possible outcomes from 2n throws which comprise exactly n heads and n tails is (2n!)/((n!)^2)(2^2n), or (2n!)/(n!(2^n))^2 (because 2^2n is (2^n)^2).

This gives us the following results:
  • For 2 throws, the probability of 1 heads and 1 tails is 0.5, or 1 in 2 (which is pretty obvious, because the outcomes are HH, HT, TH, TT, and 2 of those 4 outcomes comprise 1 head and 1 tail).
  • For 4 throws, the probability of 2 heads and 2 tails is 0.375, or 1 in 2.666...
  • For 6 throws, the probability of 3 heads and 3 tails is 0.3125, or 1 in 3.2
  • For 8 throws, the probability of 4 heads and 4 tails is 0.2734375, or 1 in 3.657...
  • For 10 throws, the probability of 5 heads and 5 tails is 0.24609375, or 1 in 4.063...
To answer our original question:
  • For 100 throws, the probability of 50 heads and 50 tails is 0.079..., or 1 in 12.564...
Looking further ahead:
  • For 1000 throws, the probability of 500 heads and 500 tails is 0.025..., or 1 in 39.643...
So there is a little more than a one in thirteen chance of getting exactly fifty heads and fifty tails in one hundred throws of the coin. Far from a dead cert, it is true, but more likely than I would have expected.

Further reading

Monday, 17 August 2009

It's always darkest before the dawn

I wish to take issue with this proverb.

I don't mean that I object to, or don't understand, the philosophy of it. The idea that if things seem dark now then it is worth remembering that dark times are also followed by bright dawns is a sound and uplifting one. And the additional implication that the darkest and most frightening time may be precisely the moment when dawn is about to arrive carries additional reassurance. The idea that things can only get better may bring much comfort. There is, we are reminded, a light at the end of the tunnel.

No, my issue with this proverb is that it simply is NOT darkest before the dawn. Or not *just* before the dawn, anyhow, which is what we are clearly intended to interpret this as meaning.

I was up before the dawn today. A very considerable time before dawn, when it was fully dark and the stars were brightly visible but the moon was on business elsewhere, the Eastern sky began to take on a luminous blue that gradually spread across the sky. While it still remained basically dark, this luminous blue very slowly brightened, so slowly that the change was not noticeable except in its long-term effects -- the stars, I realised, were gradually and one by one going out! Of course, they were actually fading, one by one, into the increasingly brighter sky. Then, as the last stars clung to visibility, the Eastern sky started to turn lighter, not so much a deep luminous blue but nearer and nearer to white -- still a hint of blue with touches of yellow and brown and orange mixed in. When this brighter light had spread across just over half of the expanse of the sky, the first rays of dawn appeared as a tiny corner of the sun ventured over the horizon.

It was certainly not darkest before the dawn: instead, the fugitive dark yielded to a striking colour display extending over several hours culminating in the arrival of aurora.

What does this mean philosophically? That if things seem really dark then we should count on only a very gradual improvement? That although the period of gradual improvement may bring its own fanciful and diverting aspects as it happens, dawn itself is still a long way off? That things can only get very slowly better? That there may be a light at the end of the tunnel, but we have to deal with a lot more tunnel first?

I think after all I preferred the original.