What Is the Infinite Monkey Theorem?
The infinite monkey theorem is a famous thought experiment in probability theory. It states that a monkey hitting keys at random on a typewriter for an infinite amount of time will almost surely type any given text — including the complete works of William Shakespeare. The theorem illustrates the concept that given enough time, even astronomically unlikely events become inevitable.
How This Simulator Works
Instead of individual keystrokes, this simulator picks three random words from a dictionary of 274,937 English words on every iteration. The default target phrase is “I love broccoli” — but you can change it to any three valid English words. With three slots and 274,937 possible words per slot, there are 20,782,585,149,174,950 possible combinations — roughly 20782.6 trillion. The simulator runs in a Web Worker, processing up to 500,000 attempts per batch without freezing your browser.
The Math Behind the Monkey
The probability of any single attempt matching the target is 1 in 20,782,585,149,174,950. By the law of large numbers, as the number of trials increases, the observed ratio of successes converges to this expected probability. The expected number of attempts before a match is equal to the total number of combinations — around 20782.6 trillion. At a rate of several million attempts per second, this could take anywhere from minutes (with extraordinary luck) to several days.
Why Does This Matter?
The infinite monkey theorem isn't really about monkeys or typewriters. It's a powerful illustration of how probability and infinity interact. It connects to real concepts in mathematics, computer science, and physics — from brute-force search algorithms and combinatorics to the Borel–Cantelli lemma and ergodic theory. This simulator lets you watch that abstract math play out in real time.
History of the Thought Experiment
The idea traces back to French mathematician Émile Borel in 1913, who used the metaphor of monkeys typing to illustrate probability in his book on statistical mechanics. The image was later popularized by physicist Arthur Eddington and has since become one of the most recognizable analogies in mathematics. It appears in discussions of everything from the nature of randomness to the philosophical implications of an infinite universe.