“They say a million monkeys typing on a million keyboards would eventually write Shakespeare. But if they had spell check, they’d only need like half that many.”

## 3 thoughts on “Random observation from Steve whilst sitting at the coffee shop”

Comments are closed.

Haha. The million monkeys would almost certainly die before they wrote Shakespeare. Unless, of course, they also spent some time procreating, eating, and pooping. They wouldn’t even have to leave their keyboards.

i always thought it was hamlet specifically so i looked it up on wikipedia (http://en.wikipedia.org/wiki/Infinite_monkey_theorem) and learned that i was wrong… but it did have this to say about hamlet, which i enjoyed:

“Ignoring punctuation, spacing, and capitalization, a monkey typing letters uniformly at random has one chance in 26 of correctly typing the first letter of Hamlet. It has one chance in 676 (26 times 26) of typing the first two letters. Because the probability shrinks exponentially, at 20 letters it already has only one chance in 2620 = 19,928,148,895,209,409,152,340,197,376, roughly equivalent to the probability of buying 4 lottery tickets consecutively and winning the jackpot each time. In the case of the entire text of Hamlet, the probabilities are so vanishingly small they can barely be conceived in human terms. The text of Hamlet, even stripped of all punctuation, contains well over 130,000 letters which would lead to a probability of one in 3.4×10183946.

The mere fact that there is a chance, however unlikely, is the key to the “infinite monkey theorem”, because Kolmogorov’s zero-one law says that such an infinite series of independent events must have a probability of zero or one. Since we have shown above that the chance is not zero, it must be one. To consider that an event this unlikely is almost guaranteed to occur given infinite time can give a sense of the vastness of infinity.

Gian-Carlo Rota wrote in a textbook on probability (unfinished when he died):

If the monkey could type one keystroke every nanosecond, the expected waiting time until the monkey types out Hamlet is so long that the estimated age of the universe is insignificant by comparison … this is not a practical method for writing plays.”

Maybe it was supposed to be that a million monkeys could eventually type “S-H-A-K-E-S-P-E-A-R-E”? That’s only 11 letters, or 1 in 3,670,344,486,987,776.

Given 1,000,000 monkeys typing, the chance that one of them would write “shakespeare” on its first try is therefore only 3670344486.987776.

Because each letter (after the first 10) ends a new possible “shakespeare” sequence, that means 172,800 possible sequences per monkey, per day. Which means only a 1 in 21240.41948488 chance that one of the monkeys will type the sequence on a given day. That’s assuming a rate of 2 key presses per second, which is quite modest if one is simply pounding the keys.

Divide that further, and there is about a 1 in 58.19293 chance that one of the monkeys will type “s-h-a-k-e-s-p-e-a-r-e” in a given year. So, if you set forth one million monkeys at this task, and had them working round the clock without stopping, you could expect to have your 11 letter sequence in about sixty years.