Shakespeare, Monkeys and Typewriters

 

Image from Wikipedia

 

A recent Facebook post by a friend of mine (for you, Paris) raised the old story of if you had enough monkeys pounding away randomly at typewriters (hmmm … better make that word processors) for long enough it is certain one of them will replicate the whole body of Shakespearian text. It’s an interesting theory. Let’s explore it a bit, but with some simplifications otherwise my head starts to hurt (and anyway I have to go and get the groceries for tonight’s dinner soon). Let’s assume the monkeys can actually type whole words … I know that’s a bit unrealistic but let’s go with it anyway.

Let n = the total number of words written by Shakespeare (leaving aside conspiracy theories) and let v = the number of unique words Shakespeare knew (i.e. his vocabulary). Finally, let u = the total number of unique combinations of words written by Shakespeare.

The way I see it,

u = (n!)/((n+1)-v)! where, for example 6! = 6 x 5 x 4 x 3 x 2 x 1 = 720

Now, according to the website http://www.william-shakespeare.info, William Shakespeare had a vocabulary of around 21,000 words. (Others quote even more but let’s be conservative). Therefore v = 21,000

Then, Bill Bryson in his book “Shakespeare”, estimates Shakespeare’s output comprised about 1 million words. So, n = 1,000,000

Using these figures we get

u = 1,000,000!/(1,000,001 – 21,000)!

i.e. u = 1,000,000!/979,001!

We can simplify this a bit as u will turn out to be the first 20,999 terms in the series 1,000,000! or 1,000,000 x 999,999 x 999,998 x 999,997 x … x 979,002. That’s a pretty big number. I won’t work it out on my calculator right now as the battery is a little weak. Nevertheless, only one of those combinations will correspond exactly with what Shakespeare wrote. And that’s making the ridiculous assumption that the monkeys can actually spell! Hmmm … pretty long odds I think. (You can see a more formal treatment of this where monkeys are not assumed to be able to spell at http://en.wikipedia.org/wiki/Infinite_monkey_theorem).

BTW, any of my mathematician friends are more than welcome to correct me because I’m pretty sure I would have mucked it up somewhere. 🙂