The New York Times has an interesting article today examining the curious fact that certain types of terrorist organizations have an unusually high ratio of engineers among their members. An interesting point to study, no doubt, but what caught my eye was this little blunder:

William A. Wulf, a former president of the National Academy of Engineering, is, no surprise, no fan of the Gambetta-Hertog theory. “If you have a million coin flips,” he says, “it’s almost certain that somewhere in those coin flips there will be 20 heads in a row.”

This numerical gaffe is a prime example of innumeracy, a favorite topic of mine, and it is doubly bad. First, the New York Times with its old-school print-format hubris regarding fact checking should not have let this slip by unnoticed. Second, the fact that the speaker is not just an engineer, but president of our National Academy, adds insult to injury.

Probability 101

The Wikipedia says that Numeracy is the ability to reason with numbers and other mathematical concepts. In today’s world, it should be considered as important as literacy. So let’s try doing some thinking about this problem.

What should first catch your eye in this is the meaning behind “20 heads in a row.” As a programmer, you are instinctively aware that 2 to the 20th power is roughly one million. This means that the chances of flipping a true coin and having it land heads up 20 times in a row is inded roughly one in a million. Does this mean that flipping a coin a million times renders such a streak “almost certain?” Of course not.

If the chance of flipping a single head is one in two, and I flip a coin two times, am I almost certain to see one head? No. If the chances of two heads in a row is one in four, am I almost certain to see a streak of two if I flip four times? Still we intuitively answer no. It seems likely, but nowhere near a certainty. So the task in front of us is to scale this equation up and see if it changes in character as we near one million.

Pinning it Down

Determining how likely this streak is requires a frequent ruse we employ in probability. Instead of calculating the probability directly, we determine out how likely it is not to occur, then subtract that value from one.

We know that the chance of the coin flip happening in the first 20 flips is 1/2^20. We’ll call this number p. Now let’s imagine a sequence of a million coin flips. The chance of a streak of 20 heads not starting at position one is 1-p. The chance of it not happening in the sequence of coins starting at position 2 is likewise 1-p. The same probability is true for every sequence of flips from position 1 to position 999,981, the last possible start of a streak of twenty.

The chances of not seeing a coin flip in every one of those positions is found by multiplying each of their values, leading to the rather unwieldy formula (1-p)^999,981. Unwieldy, perhaps, but your scientific calculator will quickly tell you it resolves to roughly 0.39. So the chances of seeing 20 heads in a row after a million coin flips is more or less 61%. Hardly “almost certain”.

Finding Almost Certain

I’d like to think that “almost certain” is somewhere in the neighborhood of 99%. I’ll leave the calculation as an exercise for the reader, but if your calculator has a log button you will be able to determine that you will need almost five million coin tosses to achieve near certainty. And when you think about it (using your beloved numeracy) that number seems a lot more realistic. Something that has a one in a million chance of occuring would seem to be only somewhat likely to occur in a million tries. Give me five million and it’s a sure thing.

Ironically, the Gray Lady just ran an ode to fact checking a few weeks ago. Apparently that department is short on people with any sort of mathematical fluency. Perhaps they should think about hiring an engineer or two?