Sunday, December 26, 2010

Monkey on a typewriter

I got some sweets books for Christmas this year. One of those books is called "50 mathematical ideas you really need to know." It's really neat. Olivia has been sick today, so I stayed home from church with her and read a chapter on probability. It talked about the classic case of the monkey and the typewriter, saying that given enough time, a monkey could produce a work of Shakespeare by randomly hitting keys.

But how much time would he need?

Here's the short answer: a lot.

Here's the longer answer: let's say there are 30 keys on a typewriter (26 letters, a period, a comma, a question mark, and a space). Let's also assume that the monkey won't have to write an entire sonnet, but just the first three words of the famous soliloquy in Hamlet:

TO BE OR

That's eight keys that the monkey will have to hit in the correct order (including the spaces). How do you calculate that probability? Well, the monkey has a 1 in 30 chance of hitting the "T", and an 1 in 30 chance of then hitting the "O", and so on. So you multiply them all together:

30 x 30 x 30 x 30 x 30 x 30 x 30 x 30 = 6.561 x 10^11

Now, if you assume the monkey can hit one key per second, without taking any breaks for eating or sleeping, the monkey will have to type for about 20,000 years for there to be a "reasonable expectation" that it would have typed "TO BE OR." But if that ever happened, I think the monkey would be more famous for living that long.



1 comment:

Kathy Haynie said...

Have you ever heard Bill Cosby's routine about this? He says everyone would be so excited because the monkey would finally type the sentence...or so they thought...only to be disappointed in the end when the scientists realized that the monkey had typed,

"To be or not to be, that is the guzourntheit."

We quote the last part of that fairly often, referring to oddball situations as a guzourntheit.