Search

Sorry, Shakespeare: Why Monkeys Won’t Write Hamlet

Art by Melody Jiang and Ryder Lariviere

It’s a widely accepted idea that monkeys, given infinite time, can type out the complete works of Shakespeare. And yet, it’s also deceptive. Though the “infinite monkey theorem” holds in an ideal universe—where monkeys never go extinct and the cosmos subsists forever—modeling the situation in real life quickly goes sideways. If we consider the finite lifespan of the universe, the likelihood of Shakespeare’s folio—or even far shorter works—being randomly generated falls to nearly zero. 

Proving the “infinite monkey theorem,” in its traditional form, is a straightforward exercise in probability. Let’s view Shakespeare’s folio as a block of n letters and give a monkey a typewriter with thirty keys. Then, the chance that the monkey does not succeed in the first x blocks of n letters is f(x)=(1-1/(30^n))^x. At first, f(x) is nearly identical to one; the monkey is almost certain to fail. But as x approaches infinity, the value of f(x) converges to zero, shrinking through repeated multiplication by a fraction of one. Thus, Shakespeare’s works are guaranteed theoretically to appear somewhere in the typewriter’s unimaginably, perhaps infinitely long printout. 

However, this approach does not work in a non-ideal universe. Stephen Woodcock and Jay Falletta, researchers from the University of Technology Sydney, put the finite monkey theorem to the test. In their study, Falletta and Woodcock found that the success rate of random generation was surprisingly low even for simple phrases. A single chimpanzee only has a 0.05 probability of typing “bananas” at any point throughout its thirty-year lifespan. For the slightly longer sentence “I chimp, therefore I am,” this probability becomes 10^(-25). “The chance of even a coherent sentence arising at random is vanishingly, vanishingly small,” Woodcock said. 

Next, the researchers calculated what would happen if the entire chimpanzee population arbitrarily typed away until the heat death of the universe: a period of 10^100 years. The results were shocking. Woodcock and Falletta intuited that the decaying likelihood of replicating text would be too rapid for generating any non-trivial piece of literature. This prediction was correct, but not extreme enough. Under the given conditions, the chance of replicating Curious George—a children’s book shorter than most essays—within the next 10^100 years is an astonishing 10^(-15043). This probability was calculated using the equation f(x)=(1-1/(30^n))^x by substituting appropriate values of n and x. That’s many, many orders of magnitude smaller than the roughly 10^(-80) chance of picking a single atom at random out of all the matter in the entire universe. “You very, very quickly go from ‘this will happen’ to ‘this might have happened’ to ‘this almost certainly won’t happen’ to ‘the universe doesn’t have enough resources for this to happen,’” Woodcock said. 

In our day-to-day lives, it’s common to conflate enormous numbers with infinity. For practical purposes, this rarely poses an issue. However, applying this belief to mathematical questions can lead to incorrect conclusions, and Woodcock and Falletta’s efforts help to highlight the fallacy. “A lot of people think infinity just means the biggest number that they can relate to, and it doesn’t,” Woodcock said. Rather, infinity is not a number or a concept that can be related to using any finite scale. Even the universe’s lifespan, which appears endless, pales in comparison to the sheer magnitude of the number needed to make the finite monkey theorem feasible. 

This discovery turns one of popular science’s favorite hypotheses on its head, and in the process, it touches on a topic that is particularly salient today. Although monkeys are not able to recreate Shakespeare’s work, the idea of probabilistic text generation has evolved and is the core of present-day AI language models. ChatGPT, Claude, and other chatbots can write works like Hamlet at the click of a button. “Purely random text generation quickly kind of falls off the rails,” said Woodcock. But modern AI is not guided purely by chance, giving it the capacity to succeed where its predecessor fails. These models utilize a far more sophisticated version of randomness, incorporating past and present data into the probabilistic “decisions” they make. 

This leaves us with a philosophical question to ponder: are the results of artificial intelligence—a duplicate of Shakespeare’s complete works, for instance—closer to the purely chance-driven typing of monkeys or the cognition of human minds? And does it matter, if the final product is identical? Thus, the old question and new findings of the (in)finite monkey theorem remain relevant, even in today’s age.