Math's Eye View

Numbers in the natural world and everyday life

Have Monkeys Typed Shakespeare?

Have virtual monkeys written Shakespeare?

monkey typing on a laptop
Beating the bard at his own game?
http://bluntmonkey.wordpress.com/contact/
It was all over the media. "Virtual Monkeys Write Shakespeare" proclaimed the BBC website. "Monkeys type out the entire works of Shakespeare by hitting random keys... prove adage about the laws of probability," said The Times of London. Within a day I did three radio interviews, for stations in France, the UK, and Russia.

It's an interesting case study in how the media feature mathematics and science. If you read the headlines, you got the impression that something highly significant had happened. If you got as far as reading the articles, you discovered that the most significant feature was the use of cloud computing and a programming tool called Hadoop. The monkeys... well, their role wasn't quite what the headlines suggested.

I don't mean that they weren't real monkeys. That goes without saying. When a team from Plymouth University tried real monkeys in 2003 their Celebes crested macaques typed five pages reading "SSSSSSS...." and then wrecked the keyboard. These were virtual monkeys. But did they write Shakespeare? Yes... and no.

Find a Therapist

Search for a mental health professional near you.

Aristotle, in his Metaphysics, pointed out that random arrangements of atoms could create any form whatsoever. Later he made an analogy with Greek plays, for which the ‘atoms' were letters of the alphabet. Cicero, disputing atomic theory, remarked that one "may as well believe that if a great quantity of the one-and-twenty letters, composed either of gold or any other matter, were thrown upon the ground, they would fall into such order as legibly to form the Annals of Ennius," commenting "I doubt whether fortune could make a single verse of them."

Cicero was wrong — but the feat would require more gold than the universe contains; indeed, more gold than it can contain, even if it were nothing but gold.

Gold letters were updated to monkeys in 1913 when the French probabilist Émile Borel wrote about thermodynamics. Explaining that molecules of air bounce around at random, and that in theory they might all collect together in one corner of a room — violating basic thermodynamic principles — he remarked that in practice this would be far less probable than a million monkeys randomly typing all the books in all the world's libraries.

Unlikely, yes: impossible, no. The Infinite Monkey Theorem proves that however improbable such an occurrence might be, it is virtually certain to happen if one monkey keeps typing random characters for a very, very, very long time. In order to produce the 3.7 million characters in Shakespeare, in perfect order, for instance, the monkey would have to type for a mere 10 to the power 6 million years. That's 1 followed by six million zeros. The age of the universe is roughly 1 followed by ten zeros.

Alternatively, a comparably large number of monkeys could all type in parallel. One of them would produce the entire text word for word straight away.

The project that attracted all the attention did neither of these. It was the brainchild of programmer Jesse Anderson, who wanted to test some software for ‘cloud computing', where many individuals use cheap notepads as terminals, and the actual computation is done by vast banks of servers located in a gigantic warehouse somewhere in Kansas or wherever. So he wrote short programs to produce random 9-character sequences, e-mailed to a central repository in the cloud.

Each sequence, on arrival, is compared to the text of Shakespeare. If it appears somewhere, then that small piece of text is considered to be generated. As time passes, more and more of the text gets filled in; to date, about 99.99 per cent. It's a neat way to test cloud computing, but it sheds little light on the Infinite Monkey Theorem, which is about getting all of Shakespeare in one go. Anderson's project is more like generating single characters at random, and every time you find one that's somewhere in Shakespeare you highlight it with a yellow pen. You will soon highlight "TO BE OR NOT", and the rest is equally easy. Replace individual characters by 9-character sequences, and that's what has been achieved.

Anderson makes all this clear on his website. Most media reports sensibly treated it as an amusing exercise. Several even managed to make the distinction between what had been achieved and what the Infinite Monkey Theorem is really about. But the headlines were usually exaggerations, and many of the articles were a bit confused.

The longest randomly-generated sequence of Shakespearian characters, to date, is the one found by The Monkey Shakespeare Simulator website. After a mere 2,737,850 million billion billion billion (simulated) monkey-years the pinnacle of its literary output was 24 characters from Henry IV, Part 2: RUMOUR. Open your ears; (the 24th character is a space).

Virtual monkeys have not written Shakespeare. They've thrown random darts at the pages of Shakespeare's Complete Works, and everything they hit has been colored yellow. So far they've hit 99.99% of the target.

 

Ian Stewart is Emeritus Professor of Mathematics at the University of Warwick.

more...

Subscribe to Math's Eye View

Current Issue

Just Say It

When and how should we open up to loved ones?