Yes, in a purely mathematical sense, monkeys could type the complete works of Shakespeare—but the probability is so astronomically small that it would not happen before the universe ends. The idea, often called the infinite monkey theorem, is a thought experiment about probability, not a practical prediction.

Where the Idea Comes From

The infinite monkey theorem has been around for over a century. It was popularized by French mathematician Émile Borel in 1913, who used it to illustrate how improbable events become when you have an enormous number of trials. The phrase “monkeys and typewriters” was later made famous by the physicist Arthur Eddington in 1928, and it has since become a staple of pop culture—appearing in books, TV shows, and even a 2011 study that actually used virtual monkeys to test the idea.

The theorem is not a real experiment. It is a way of explaining the law of large numbers: if you have an infinite amount of time, any event with a non-zero probability will eventually occur. But “eventually” can be unimaginably long.

How the Math Works

To understand the odds, you need to know two things: how many characters are in Shakespeare’s complete works, and how many keys a monkey could press. The complete works of Shakespeare contain roughly 5 million characters, including spaces and punctuation. A standard typewriter has about 50 keys (letters, numbers, punctuation, and space).

For each character, the monkey has a 1 in 50 chance of pressing the correct key. For the entire 5-million-character text, the probability is 1 in 505,000,000. That number is so small that it is effectively zero. To put it in perspective, the number of atoms in the observable universe is around 1080—a number that is dwarfed by 505,000,000, which has about 8.5 million digits.

Even if you had a billion monkeys typing a billion characters per second for a billion years, the chance of producing even a single line of Shakespeare is virtually nil. The theorem only works if you have infinite time—which, according to current physics, the universe does not have.

What the 2011 Virtual Monkey Study Found

In 2011, a programmer named Jesse Anderson ran a simulation using virtual monkeys. He used a distributed computing network to simulate thousands of monkeys typing random characters. The goal was not to produce all of Shakespeare, but to see if they could produce any of his works. The virtual monkeys did eventually produce a few short passages—including a line from A Lover’s Complaint—but only after an enormous number of random attempts.

Anderson’s simulation used a simplified alphabet (just 26 letters and a space) and targeted shorter texts. The fact that it produced a few recognizable lines is a testament to the power of large numbers, but it also shows how far we are from the full works. The simulation took months and required massive computing power, and it still only produced fragments.

Why Real Monkeys Would Fail Even Faster

Real monkeys are not random typists. They are intelligent animals with preferences and habits. A monkey sitting at a typewriter would likely press keys in a non-random pattern—perhaps favoring certain keys, or pressing the same key repeatedly, or getting distracted and throwing the typewriter. The theorem assumes perfect randomness, which real monkeys do not provide.

Moreover, monkeys do not have the physical ability to type for long periods. They would tire, lose interest, or damage the typewriter. In a real-world test, you would not get a random string of characters; you would get a short burst of activity followed by a mess. The theorem is a mathematical abstraction, not a biological prediction.

Common Misconceptions

One common misconception is that the theorem says monkeys will type Shakespeare if given enough time. It actually says they could, but the probability is so low that it is not a meaningful possibility. Another misconception is that the theorem requires only a finite amount of time—but it requires infinite time, which is not physically possible.

People also often confuse the theorem with the idea that “anything can happen.” While it is true that any finite string of characters has a non-zero probability, the probability is so small that it is effectively impossible in any realistic timeframe. The theorem is a lesson in probability, not a prediction about monkeys.

Alternatives: What Would Actually Produce Shakespeare?

If you want to produce the complete works of Shakespeare, you have two realistic options: a human typist or a computer program with the text stored in memory. A human can type the works in about 40 hours (at 100 words per minute), and a computer can do it in milliseconds. Neither involves randomness.

The monkey theorem is often used as a metaphor for evolution or for the idea that complex structures can arise from random processes. But in those contexts, the randomness is constrained by natural selection or other mechanisms, which makes the probability much higher. Random typing alone is not a viable way to produce complex text.

Frequently Asked Questions

Could a monkey type even one word of Shakespeare?

Yes, a monkey could type a single word like “the” or “and” by chance, but the probability is still low. For a 3-letter word with a 50-key typewriter, the chance is 1 in 125,000. With enough monkeys and time, it would happen, but it is not likely in a short experiment.

How long would it take for a monkey to type “to be or not to be”?

That phrase has 18 characters (including spaces). With a 50-key typewriter, the probability is 1 in 5018, which is about 1 in 3.8 × 1030. Even if a monkey typed one character per second, it would take billions of times the age of the universe to have a reasonable chance.

Is the infinite monkey theorem true in practice?

No. The theorem is a mathematical idea that requires infinite time. In the real universe, time is finite, and the probability is so low that it is effectively zero. It is a thought experiment, not a practical possibility.

Did anyone actually try this with real monkeys?

Yes, in 2003, researchers at the University of Plymouth placed a computer keyboard in a cage with six macaques for a month. The monkeys produced about five pages of text, mostly the letter “s,” and did not type any recognizable words. The experiment was more about animal behavior than probability.

Could a computer randomly generate Shakespeare faster than a monkey?

A computer can generate random characters much faster than a monkey, but the probability is still the same. Even a supercomputer generating billions of characters per second would not produce Shakespeare before the heat death of the universe. The only way to get the text is to program it directly.