It has been written, in various forms, that a monkey sitting at a typewriter tapping at random will, if given enough time, produce any piece of writing ever produced, Shakespeare’s Sonnet 18, for instance^{1}. This supposition has been used in the past to demonstrate the difference between the concepts of “infinite” and merely “mind-bogglingly massive”. Here, I will attempt to calculate the probability of this happening.

First, we need the number of keys on a standard typewriter keyboard. Easy enough – discounting special keys such as shift and backspace, there are approximately 50 keys.
There’s also no need to make things overly difficult – we are talking about a monkey, after all – so we’ll discount capitalisation, italics for stage directions and such.

Then we need the exact length of Sonnet 18. A quick meander around the Internet tells me it is 115 words long, including 619 characters. Surely not too daunting a task for a determined primate? And because we’ve promised him a banana when he’s done, he’s very determined indeed.

So, onto the calculations. If the monkey were only given one shot at this, one shot at glory, he would have to get the first character right on the first strike, the second character right on the second strike, and so on. Given 50 keys on a typewriter keyboard, the probability of getting each character right is simply (1/50). Given 619 characters in Sonnet 18, the probability of getting each one exactly right in the correct sequence is (1/50)^{619}. This comes to 2,1755412185774780362325532940389 x 10^{-1052}, a truly miniscule number.

Clearly, our monkey isn’t likely to manage this feat on the first go. To calculate the probability of anything else, we’re going to have to figure out exactly how many chances he’s likely to have. Typing continuously, he has a chance to start the winning sequence every time he strikes a key.

First, how fast does this monkey type? Let us assume that this monkey, while not particularly accurate, can type at a speed rivalling the fastest human – this is, to date, Barbara Blackburn, who can maintain 150 words per minute for nearly an hour. As this measurement assumes a word to be five letters and a space, this is 900 characters per minute, 15 characters per second which corresponds to a period of 0,06 (recurring) seconds per character, which for the sake of my sanity I’m going to round down to 0,06 seconds per character.

So every 0,06 seconds our primate friend is striking a key, and that key may or may not start the correct sequence. Now, how many keystrokes is he likely to get in? Given his remarkable longevity (members of Atelis longlifidae are prodigiously long-lived), we will give him, literally, until the end of the world to get it done.

There are many theories regarding how long we have to wait until the Earth meets its maker, ranging from about five years (the Incas believed that 2012, by our measurement, was a good time to start panicking) to approximately 5 billion years (when the Sun is estimated to become a Red Giant, boiling off the oceans and expelling the ol’ blue-and-green into the void). I’m an optimist, so five billion years seems a good place to start.

Five billion years is 1 826 250 000 000 days, which is 43 830 000 000 000 hours, or 157 788 000 000 000 000 seconds. This is time enough for 2 366 820 000 000 000 000 of our monkey’s keystrokes. Because it’s not good enough to merely begin the winning sequence – he also has to have time to finish it – we’ll subtract the number of keystrokes that will take, from the total, leaving us with 2 366 819 999 999 999 381 chances to initiate the sequence of characters that will leave us Sonnet 18.

So, given 2 366 819 999 999 999 381 chances to get it right, our monkey has a probability of 2 366 819 999 999 999 381 x 2,1755412185774780362325532940389 x 10^{-1052} or 5,1491144669535452190559174879383 x 10^{-1034} of getting it right before the world ends.

Still no cigar, and not even close. So obviously our monkey needs some help. For this, we have the patented Monkey Cloner 6000™, the latest in primate replication technology. It’s very easy to use – we just have to set the dial for how many monkeys we want, and it does the rest. So how many monkeys *do* we want?

To be certain of having this task done in time, we need to make the probability of it equal to 1. 5,1491144669535452190559174879383 x 10^{-1034} goes into 1 (1,9420815101662448575607332403532 x 10^{1033}) times, so in fact that is how many monkeys we’re going to need if we were going to get this done.

Of course, 1,9420815101662448575607332403532 x 10^{1033} monkeys are going to take up a lot of room. And a lot of bananas. Assuming one banana each (no favouritism, here) it’s about 2,4276018877078060719509165504415 x 10^{1029} metric tonnes of bananas, or 1,5462432405782204279942143633382 x 10^{1022} times more than is produced on Earth every year (about 15,7 million tonnes). Then again, we have until the end of the world to produce this many bananas, meaning that we only have to up banana production by less than 3,0924864811564408559884287266764 x 10^{1012} tonnes of bananas per year and sustain that for 5 billion tears to produce enough.

Hence, I believe we can put the issue to rest. Never again can a reasonable person argue that Shakespeare was in fact a monkey, due to the sheer improbability of Sonnet 18, not to mention the lack of 17^{th}-Century typewriters. Nor, indeed, could they argue that Shakespeare was in truth 1,9420815101662448575607332403532 x 10^{1033} monkeys, as although he (they) may have produced Sonnet 18 given enough time, the world banana economy would simply not have sustained him (them).

^{1}In the first draft of this w/u, I used the complete text of Hamlet, but the numbers involved produced errors on scientific calculators, Microsoft Calculator and Google Calculator alike. I am not above admitting defeat, especially to numbers like (1/50)^{167173}.