Post navigation

Infinite monkey theorem postulates around the idea that “a monkey hitting random keys on a typewriter (or in today’s context, a keyboard) for an infinite amount of time will almost surely type a given text, usually defined as the complete works of William Shakespeare.” 😀

When events are independent, the probability of them all happening is the product of the individual probabilities multiplied together. Think of it this way, the first word in the first line of Hamlet is “Who’s there?”. If we omit spaces, capitalization and punctuation for simplicity sake, we get “whosthere”.

The probability of the first letter correctly being “w” is 1 out of 26 (W being 1 letter out of the 26 in the alphabet). The probability of the second letter being “h” is the same, 1/26, and so on and so forth.

Therefore the probability that a monkey will correctly type the first line of 9 letters is:

Which equals 0.00000000000018417% or for those of you who are counting. Given that Hamlet has about 130,000 characters in it, the probability of a monkey typing it out is 1 in 3.4 × 10183,946. It also means that the monkey needs to type that many letters before he or she completes Hamlet.

If the world were filled with monkeys typing for all time, their total probability to produce a single instance of Hamlet would still be less than one in 10183,800.