Nominations and Campaigning for the 2022 RationalWiki Moderator Election are now closed. The election booth is now open!

# Monkey typewriter theory

An ape typing William Shakespeare Christopher Marlowe.
 Part of aconvergent series onMathematics 1+1=11 v - t - e
 “”Come to think of it, there are already a million monkeys on a million typewriters, and Usenet is nothing like Shakespeare. —Blair Houghton
 “”It was the best of times...it was the blurst of times? You stupid monkey! —Mr. Burns

The monkey typewriter theory hypothesis theorem[note 1] says that if a certain (large, often considered infinite, depending on who's saying it and what number they can think of randomly) number of monkeys were given typewriters and a really long time,[note 2] they could write the works of some random famous writer (e.g. Shakespeare, Dickens, etc. — it doesn't really matter[note 3]). A similar idea is that patterns could be found within the value for pi,[note 4] as the digits after the decimal point are essentially random and infinite.[1]

The more general idea behind these poetic conjectures is that, given a sufficient amount of time, anything that squares with the laws of nature is theoretically possible. However, the time frame required for a bunch of monkeys randomly banging on a keyboard to produce the works of Shakespeare is longer than the anticipated existence of the Universe. So this wiki is screwed. Damn, we tried.

However, it is a scientifically proven theory that if you give five (drunk) monkeys typewriters, and one minute, all of the resulting text would make more sense than anything Gene Ray says.[citation NOT needed]

## Ze math

Suppose that there are 10 billion monkeys working on 10 billion typewriters. If each monkey can type 10 characters per second, what are the odds that they compose Hamlet within the age of the Universe?[note 5]

Hamlet has about 100,000 characters, and a decent typewriter might have 44 keys. If the monkey is typing randomly, and we don't care about case sensitivity, the probability that it hits the right sequence of keys to produce Hamlet is something like ${\displaystyle \left({\frac {1}{44}}\right)^{100,000}}$, or 1 chance in 10164,345.

If there are 10 billion monkeys who start typing at the Big Bang at a rate of 10 keys per second, and continued non-stop until the present day (a time period in the ballpark of 1018 seconds), the probability that they would have composed Hamlet by now is about 1 chance in 10164,316. Yes, that number is a 1 followed by 164,316 zeroes.

Of course, if the monkeys are YECs, their universe is only 6,000 years old (about 1011 seconds to an order-of-magnitude approximation). Then the probability becomes even worse, about 1 in 10164,329.

The point to all of this is that even with a gigantic population of monkeys (more than the human population of Earth) typing at a fairly fast pace over a time period that, for all intents and purposes on a human scale, is forever, the probability of coming up with a particular work of Shakespeare is so minuscule as to be zero in any practical sense.

On the other hand, if you have 4.7×10164,345 monkeys (which is way more than the number of atoms in the observable universe but just saying that it has theoretical basis), the probability to finish it within the first 100,000 characters (of each typewriter) becomes 99%.[note 6]

## The Paignton Experiment

In 2003, a group of researchers from the University of Plymouth placed a computer in the monkey enclosure of the Paignton Zoo for a month and gave the monkeys access to the keyboard in order to test this theory.[2]

After initially attempting to destroy the keyboard, then urinating on it, the monkeys did eventually produce some five pages of writing, mostly repetitions of the letter 'S' — which puts to rest the assumption of "jabbing randomly" assumed above, so add a few more zeros to those numbers. Although the experiment was described as having "little scientific value", it did show that while monkeys probably won't make good authors, they might quite possibly have a future in the performing arts, or on Wikipedia.

## Computer experiments

In 2011, a computer based project by US programmer Jesse Anderson tried out the monkey-typewriter method to generate the works of Shakespeare using Amazon.com's cloud computing resources.[3] The method required the random generation of a 9-character string by a digital "monkey" that was then checked against known works by Shakespeare. These were then selected in an evolutionary algorithm to complete the 3 million or so characters needed to complete Shakespeare's work. Though this does have some differences to the actual monkey-typewriter hypothesis, which relies on purely random chance and a long, long time — multiple times the expected age of the universe.[note 7] Anderson's work is more like Dawkins' weasel but on a scale far grander than a single sentence.

As an April Fool's joke in the year 2000, S. Christey of "MonkeySeeDoo, Inc." created an official Internet RFC entitled The Infinite Monkey Protocol Suite (IMPS) that "describes a protocol suite which supports an infinite number of monkeys that sit at an infinite number of typewriters in order to determine when they have either produced the entire works of William Shakespeare or a good television show. The suite includes communications and control protocols for monkeys and the organizations that interact with them."[4]

Yes, if you take into account genetic and technological drift.[note 8]

## Commentary from a monkey

sssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssaaaavalvgggggggggggv-vasssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssmmmmmsssssssmmmsssssss

Clearly this is from one of the earlier works of Shakespeare.

## The power of infinity

While everything said above is absolutely correct, the assumptions include a finite albeit large number of monkeys (10 billion in the given example) and a finite albeit long time (since the big bang in the given example). With these finite assumptions, it is imaginable that monkeys would be defeated in their endeavor. Now, if there were infinite number of monkeys which were given infinite amount of time, then they would produce all the books already written and all the books to be written. Not impressed? How about this then: if one monkey was given infinite amount of time, then it would still produce all the books already written and all the books to be written. And more amazingly, if infinite number of monkeys were given a mere second[note 9], they would still produce all the books already written and all the books to be written in a jiffy. This is the power of infinity.

Notice that infinity is only (and only) a mathematical concept and not a physical possibility. This means everything in the world (including the number of monkeys and the time passed since the big bang, along with the number of atoms in the universe/multiverse and basically anything you can think of) is finite, and as a result the idea of monkeys producing Hamlet remains impossible in reality.

## Notes

1. it is not a theory, because it is not an explanation for a body of evidence with predictive power. It is also not a hypothesis because it is only an almost testable (where/how do you prepare an infinite number of monkeys?) statement. It is a theorem because it is a deduction from (other) simpler logical statements/truths.
2. Unless you are using an uncountably infinite number of monkeys, then it can usually be done in a very short amount of time.
3. Of course, if you expect non-English works, you might need corresponding typewriters.
4. In formal language, "pi is disjunctive in base 10"; it's not strictly proven yet, but is strongly suspected.
5. Variants of this problem can be found in various textbooks on statistical mechanics and thermodynamics.
6. Derivation: probability of matching after ${\displaystyle n}$ trials each with probability ${\displaystyle p}$:
${\displaystyle P=1-\left(1-p\right)^{n}}$
so if you have ${\displaystyle n={\frac {1}{p}}}$, for large enough numbers
${\displaystyle e^{-1}=\lim _{n\to \infty }\left(1-{\frac {1}{n}}\right)^{n}}$
Where ${\displaystyle e}$ is the base of natural logarithm. For ${\displaystyle n={\frac {k}{p}}}$, you have
${\displaystyle 1-P=e^{-k}=\lim _{n\to \infty }\left(1-{\frac {1}{n}}\right)^{kn}}$
So if we work backward from 99%, which is ${\displaystyle 1-P=0.01}$ solve for ${\displaystyle k}$ gives ${\displaystyle k=4.60517}$ and so ${\displaystyle n={\frac {k}{p}}=4.60517\times 10^{164345}}$. Obviously.
7. In fact, and considering the sheer length of Shakespeare's complete works, one would expect to find shorter writings, such as this very article, appearing randomly long before and far more often than his.
8. Although this viewpoint might also imply that all literary works to date are indistinguishable from connecting randomly selecting words.
9. (and sufficient typing speed)