An infinite number of monkeys with typewriters

This is how I plan to write my blog in future. I will keep this little guy in my basement and supply him with bananas until he produces an article I’m happy with. It’s a great method if you’re lazy but patient.

But how patient would I have to be? How long would it actually take?

It’s commonly said that an infinite number of monkeys with typewriters would type out the entire works of Shakespeare. Let’s do some maths and find out just how many monkeys you would need to do this and how long it would take. The answer may surprise you.

First, let’s do a simple example. Let’s sit one monkey down with a typewriter and wait while he types some letters. Let’s give him a really basic typewriter with only 50 keys (the keyboard I’m currently typing on has 105 keys.) Let’s assume that the monkey hits keys purely at random. What is the probability that the monkey types the word monkey?

Well, the probability of typing the letter “m” first is 1/50. The probability of typing the letter “o” second is also 1/50, and so on. Since each letter typed is assumed to be chosen independently of previous letters, the probability of typing monkey is:

(1/50) * (1/50) * (1/50) * (1/50) * (1/50) * (1/50) = (1/50) ^ 6

i.e. one fiftieth raised to the power of 6 (because there are 6 letters.)

This is approximately 1 chance in 15 billion. To have any reasonable expectation of getting a monkey to type the word monkey, we would need to wait a very long time. How long? If each key press takes 1 second, then we would have to wait something like 20 billion seconds, or 500 years.

And that doesn’t include toilet breaks, or time spent picking fleas off your friends.

But what about the entire works of Shakespeare? Shakespeare’s works contain something like 4 million characters (the precise number doesn’t bother me greatly – I’m sloppy like that.) So the chance of typing the whole of Shakespeare’s works without errors is:

(1/50) ^ 4 million

i.e. one fiftieth raised to the power of 4 million, or 10^-6795881.

Unless you’re a mathematician, you’ll probably have only a vague notion of what this means. For comparison, the age of the universe is “only” 4.3 * 10^17 seconds, and the number of atoms in the observable universe is estimated at 10^82 . So even if you had one monkey for every atom in the universe, and they had all been busy typing (without a single toilet break) since the Big Bang, the chance of one of them typing the complete works of Shakespeare would still be utterly negligible.

So damn! My plans for outsourcing my blog to chimpanzees just isn’t going to work, no matter how many bananas I feed them.

Bonus information: in 2003, Paignton Zoo gave a group of 6 monkeys a keyboard connected to a computer to see what they would do with it. After one month, they had typed five pages of the letter “s” and had broken the keyboard.

Thanks to Wolfram Alpha for help with calculating the numbers in this article – my pocket calculator exploded when I tried to do it. By the way, if any of you maths fiends spot any errors in my calculations, please do point them out!

Advertisements

23 responses to “An infinite number of monkeys with typewriters

  1. Some might say that if you gave six typical residents of Paignton the same, then the result would not differ greatly.

  2. Because I’m also a little lazy, I’m letting my monkeys check to see if your calculations are correct.

  3. This math fiend is going to trust in your math. Okay, I’m lazy, too. 😉 Even if your math were flawed, the basic concept still stands…let’s not wait on monkeys to do our typing for us. 😉 What I’m wondering is why the monkeys at the zoo were so enchanted with the letter s.

  4. yes, I am quite sure that there is one wrong digit in your post. My monkey pointed it out. Have your monkey call my monkey and I am sure that, given enough time, they will work it out. I am happy to inviite Iva’s monkey to join them, just to keep things moving along. Hope you can find some chocolate covered heart shaped bananas to give to your little helper on Valentines Day. (do you celebrate Val Day on your side of the pond?) Oh, and to nerdinthebrain, I think that the monkey were likely hoping that if they typed the s’s enough, one would come out backwards, and the two s’s together would form a heart. I am sure of that because I am quite sure that the monkeys are also always happy to have a bit more love.

    Happy Valentines Day.

    • Some good ideas there, Paula. As for Valentine’s Day, yes we celebrate it in general here, but me personally, not really. I cooked my wife a nice meal this evening with a glass of wine, but I do that every Saturday 🙂

  5. I think you should just lower your standards. I mean, who says: adjfkdljafieo;wnfnk is not great prose? I mean, dude, it’s all relative. 🙂

    And give the monkeys some flea-picking breaks. That’s a God-given right. If you don’t, they may form a union and then you’d better have a large bucket of bananas at your disposal.

  6. Add caffeine to their food. That will speed them up.

    Your number is larger than a googolplex. http://en.wikipedia.org/wiki/Googolplex

  7. Shakespeare’s works are already written. What’s the need for reproducing it with monkeys? I guess, Shakespeare is taken here as an example of a timeless literary genius. So, what’s the probability that a monkey would type something that can be considered classic and will be read 800 years later? How is such standard defined? As rung2diotimasladder mentioned, “who says: adjfkdljafieo;wnfnk is not great prose?”

    • Well, what this thought experiment clearly demonstrates is that pure randomness doesn’t get you very far. What’s needed is structure and patterns. Then things start to scale very rapidly.
      In the lifetime of the universe, and using just the atoms available, you can produce not just the works of Shakespeare, but also Shakespeare himself.

      • Can you recalculate the time assuming the monkey types one letter every Planck time interval? Would it still be longer than the age of the universe? Most likely, it would.

        But this is an interesting thought. What appears random to us is not random at all.

  8. You mean the secret to blogging success isn’t having an army of monkeys produce quality blog posts?!? Dammit, now I have to revise my whole blogging strategy. Thanks a lot Steve 🙂

    • Of course randomness doesn’t encode any information. For that we need to generate non-randomness, or patterns. We might even like to refer to these as self-aware patterns. That might even be a good name for a blog 🙂

  9. agrudzinsky, the Planck time is 10 ^ -44 seconds, so that doesn’t significantly change things. The monkeys still won’t get anywhere close to reproducing Shakespeare.

  10. agrudzinsky, what did you mean when you said that what appears random, isn’t?

  11. Maybe they aren’t typing randomly, but instead are writing in their own monkey language. Or maybe they’re writing in code because they’re plotting their escape from the typing room. /bad joke

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s