BlurHashApen

Can a Monkey Imitate Shakespeare?

Give an infinite number of monkeys an infinite number of typewriters and eventually they will write one of Shakespeare’s works. This is the "infinite monkey theorem”. But is it correct?

Just imagine: an infinite number of monkeys pressing random keys on a keyboard for an infinite amount of time. What is the probability that, at some point, they will press a combination of keys that results in a complete copy of one of the masterpieces of William Shakespeare?

One chance in ...

This is about pure mathematical probability. Setting aside punctuation and capital letters to keep it simple, this leaves 26 letters in the alphabet that the monkeys have to type in the correct order. A monkey bashing away on a special typewriter with 26 letter keys then has a 1 in 26 chance of hitting the first letter of Shakespeare's "Hamlet”.

Hamlet begins with the phrase "Who's there?”. The probability of the monkey hitting an 'H' after the 'W' is 1 in 262, or 1 in 676. The chance of typing the first 20 letters correctly is therefore 1 in 2620, which is approximately 1 in 20 octillion (i.e. 20 with 27 zeros after it). So let’s keep calculating: to type Hamlet, a text consisting of about 130,000 letters, with no errors, you get a probability of 1 in 26130,000. In other words it is almost impossible. Even with an infinite number of monkeys, it would take an incredibly long time to do it.

Billions of monkey years

So what if we switch from theory to practice? Getting your hands on an infinite number of monkeys is difficult, but fortunately we have the virtual monkeys created by data engineer Jesse Anderson. In 2011 he created millions of coded "monkeys" and compared the gibberish they produced to the works of Shakespeare. Eventually they did manage to complete all 38 of Shakespeare's works.

To be fair, however, this amazing success did require a helping hand from Anderson. His virtual monkeys did not have to type a whole work in the correct order. They only needed to produce blocks of nine letters of text that could appear anywhere in any of Shakespeare's works.

A number two

So what happens if we give the keyboard to some real monkeys? Researchers at the University of Plymouth tried this. They put a keyboard in the monkey enclosure at Paignton Zoo for a month. It is no exaggeration to say that the monkeys were extremely bad.

The total result was only five pages of characters, mostly containing the letter "S" and only one vowel, "A”. What is more, the alpha male started becoming aggressive and hitting the keyboard with a rock, and after that the other monkeys decided to do a “number two” on it. According to the supervisors at the zoo, the experiment had very little scientific value, except to show that it may take some time before monkeys produce another Shakespeare.