The Infinite Monkey Theorem: The Odds of Randomness

Published 1-23-23 | Last Update 1-23-23

Have you ever heard of the Infinite Monkey Theorem? It's a thought experiment that goes something like this: if an infinite number of monkeys were typing randomly on an infinite number of typewriters, they would eventually type out the complete works of William Shakespeare.

The theorem, which was first proposed by French mathematician Emile Borel in 1913, is often used to illustrate the concept of probability and the odds of seemingly unlikely events occurring given a large enough sample size.

But just how likely is it that the monkeys would actually type out Shakespeare's works? To calculate the probability, we can use the following formula:

$$P = \frac{s}{k^n}$$

Where:

image info

In this case, the number of possible outcomes for each trial (k) is the number of characters on a typewriter keyboard (around 50-60, including letters, numbers, and symbols). The number of trials (n) is the number of characters in the complete works of Shakespeare (around 884,647).

Plugging these numbers into the formula, we get:

$$P = \frac{1}{(50-60)^{884,647}}$$

Which simplifies to:

$$P = \frac{1}{5.5 x 10^{1153}}$$

This probability is so small that it's practically zero. To put it in perspective, it's roughly equivalent to flipping

print("hello world")
x = 4 + 5