A monkey seated at a typewriter, given infinite time, will eventually produce the complete works of William Shakespeare. That classic thought experiment, known as the infinite monkey theorem, has delighted mathematicians for more than a century. But a new analysis shows that when real-world limits such as time and resources are taken into account, even a smarter, educated version of the monkey still faces odds so long they might as well be impossible.
The idea traces back to the French mathematician Émile Borel, who in 1913 imagined a million monkeys typing diligently for a year and filling libraries with every book ever written. The modern version of the theorem states that a monkey hitting keys at random for an infinite amount of time will almost surely type the complete works of William Shakespeare. On paper, the math checks out: anything with a nonzero probability will eventually happen if you wait long enough. In practice, “eventually” turns out to be longer than the age of the universe — by many, many orders of magnitude.
Earlier calculations had already made this clear. One careful study estimated that the expected number of keystrokes needed for a random monkey to produce Shakespeare’s entire corpus is a 1 followed by 7.45 million zeros. The paper, published on arXiv by mathematician Ioannis Kontoyiannis of the University of Cambridge, builds on that work and introduces a clever twist.
Instead of a monkey typing completely at random, Kontoyiannis considers an “educated monkey” that still types randomly but is constrained to produce only statistically typical English text — strings that are grammatically and syntactically correct and resemble real writing. This restriction cuts out all the meaningless gibberish, so the time required to hit any particular passage should drop dramatically. Information theory provides a straightforward way to calculate exactly how much.
The key concept is the entropy rate of English, a measure, expressed in bits per character, of how much uncertainty or information is contained in typical written English. Using one of the most reliable recent estimates, 0.863 bits per character, and applying a fundamental result known as the asymptotic equipartition property, Kontoyiannis shows that there are roughly 2 raised to the power of (length times entropy rate) typical strings of any given length, each equally likely. The average waiting time to produce one specific typical string of length ℓ characters is therefore about 2 raised to the power of (ℓ times h) keystrokes.
To turn that into years, the paper assumes a realistic typing speed of 52 words per minute (the human average), with five characters per word including spaces. That works out to roughly 1.367 × 10^8 characters per year if the monkey types nonstop, 24 hours a day. The result is that “on the average, it takes about 7.3 × 10^{0.26ℓ−9} years for a typical English text of ℓ characters to be produced by an educated monkey typing at random,” the study reports.
Compare that with a purely random monkey using a 27-character alphabet (lower-case letters plus space). The corresponding rule is far worse: roughly 7.3 × 10^{1.43ℓ−9} years. The educated monkey’s time grows much more slowly with length, giving it an enormous practical advantage.
Kontoyiannis illustrates the difference with concrete examples. Muhammad Ali’s two-word poem “Me, we” would appear in the educated monkey’s output in about 4.6 seconds, versus 38.2 days for the random monkey. The Terminator’s line “I’ll be back” would take the educated monkey 2.8 minutes instead of 40 million years. Even longer passages still improve dramatically: Franklin D. Roosevelt’s “The only thing we have to fear is fear itself” would require 3,658 years from the educated monkey, while the Spice Girls’ chorus “I’ll tell you what I want, what I really really want” would take 73,000 years. Yet the paper notes that these times quickly exceed any meaningful human timescale.
For full-length literary works the numbers become astronomical again. Hamlet’s famous soliloquy “To be or not to be” would take the educated monkey about three hours and four minutes. But the entire play of Hamlet would still demand an unimaginably long 10^{42,277} years. For comparison, a purely random monkey would need 10^{232,784} years, and both figures vastly larger than the 1.4 × 10^{10} years astronomers estimate for the age of the universe.
Citations
Ioannis Kontoyiannis et al. Shakespeare, Entropy and Educated Monkeys. ArXiv. Published online December 8, 2025. DOI: 10.48550/arXiv.2512.11880
