The Math Forum

Ask Dr. Math - Questions and Answers from our Archives
Associated Topics || Dr. Math Home || Search Dr. Math

Infinite Monkeys on Infinite Typewriters Producing Shakespeare

Date: 01/02/2006 at 08:18:18
From: Steen
Subject: Infinity and singularities

I know you have already dealt with a question pertaining to the 
infinite monkeys example, but I still haven't heard a satisfactory 
explanation as to why (given an infinite amount of time, monkeys, and 
trials) they absolutely will pound out all the works of Shakespeare.  
Why is it that, given a finite goal and infinite time and trials, it 
becomes a certainty that the goal will be attained?  

This question has been discussed to death in my apartment, and I still
don't know, probably because we're all bio majors.  I think one of my
roommates understands, but he couldn’t explain it well and his answer
got me nowhere nearer to understanding, much like the explanation
already posted on this site in response to a similar question.  It all
seems like a bunch of hand-waving to me.  But I think the critical 
difference between the question already posted here and mine is this: 
they asked IF the monkeys will do it.  I am asking how we KNOW they 
will do it.

Assuming the letter generators (monkeys) were random in the truest 
sense, why would they have to play out all possible combinations?  
And how?  I found the lottery ticket analogy extremely unsatisfying, 
as it did not seem random at all.  It was a man who set out to do 
every single possibility there was, and did not stop until he did.  
But it doesn't seem to me that randomness has any such goal, and will 
not set out to complete all possible outcomes.  Plus it seems to me 
that some possibilities will contradict all others, for example the 
possibility of every generator popping out nothing but strings of A's 
for all eternity.  True, this is even more unlikely than Shakespeare's
works being reproduced, but it is still a possibility so why is it
that this won't be the case?

I know that to realistically represent the probability of this 
happening, the chances of another A popping out goes down each time 
another one is produced.  But no physical characteristics of the
letter generators are changed such that it would become more difficult
for the letter A to be produced (they don't run out of the A-grade ink
or something), so each event of a letter popping out can be viewed as
a separate, isolated occurrence.  Each time, A has just as much of a 
chance of coming out as any other letter, so it shouldn't be 
surprising each individual time it does.  Why can't Rosencratz and 
Guildenstern's coins come up heads for all eternity?

And it's not that I don't think something seemingly cognitive or pre-
meditated can come out of randomness, so perhaps the all A's was a 
bad example.  What if all the works of mankind were reproduced in 
their entirety except for any of Shakespeare's, even Robert Jordan's 
immense series?  Even those that reference Shakespeare.  And then all 
new works, never written by mankind, started popping out.  And more 
new works were continued to be produced ad infinitum, but never any 
Shakespeare.  What makes it a certainty that Shakespeare will be 
reproduced?  I accept the possibility of it happening, but what makes 
it more than that?

One of my roommates told me that, since it's impossible to measure 
this occurrence due to the infinite nature of it, we can assume all 
possibilities are played out simultaneously, even the ones that 
contradict each other.  But this sounds to me like it's just accepting 
that anything is possible.  It sounds like saying, "Well, we won't 
live long enough to prove this wrong, so we can't rule it out!"  
However, I already said that I accepted the possibility of it 
happening but not the certainty, so this is not a satisfying 
explanation.  Obviously if the first keystroke produced is a B, that 
rules out the possibility of only A's being produced forever, so 
already there can't be all the possibilities happening simultaneously.

This question has been driving me crazy!  I have a feeling that I'm 
over-thinking something, but I don't know what!

Date: 01/03/2006 at 19:52:45
From: Doctor Minter
Subject: Re: Infinity and singularities

Hi Steen!

Your logic and method of thinking are not flawed.  I especially liked 
the phrase where you mentioned that we won't be around long enough to 
prove it wrong, so we just accept it.  

Some areas of science indeed are seen in this light.  The newly-
formed M-Theory and its predecessor, string theory, fall into this 
category.  Our technology is not sophisticated enough to probe 
objects as small as strings, and there are physical laws (e.g. the 
Heisenberg Uncertainty Principle) that say that we cannot even 
THEORETICALLY probe subatomic particles to this level, no matter how 
far technology takes us.  Many classical physicists then insist that 
string theory is not a valid theory of science because it cannot be 
disproven.  The debate rages on.  I digress....

No human alive today will be around when the sun runs out of hydrogen 
to use as nuclear fuel, goes through stellar death, and becomes what 
astronomers call a white dwarf.  However, we are 100% certain that 
this will happen in a few billion years.  We have seen it happen to 
other stars, and the logic follows.

The monkey example is not that simple, I must concede.  I assume that 
no one has ever seen a monkey randomly type out a work of any person, 
let alone a Shakespearian work.  However, this example is not a 
physical example (although the methods do form a large basis of 
thermodynamics), but a mathematical one.  Specifically, it has to do 
with probability.  

Let's start simple.  Say that we watch a monkey bang on a typewriter 
until 12 characters come out.  What are the odds that those 
characters (ignoring spaces) spell "Have a nice day"?  Let's also 
simplify by saying that the typewriter keyboard contains only letters 
(no numbers, space bars, function keys, or symbols).  

To spell out the phrase, the letter h has to appear once, the letter 
a three times, the letter v once, etc.  They also have to appear in 
the correct order.  There is only one 12-letter outcome that spells 
out the phrase.  Let's figure out how many total possibilities there 

The first letter can be any of the 26 letters, as can any of them.

Thus, the total number of 12-digit output possibilities is 

  |--(12 times)--|
   26*26*26*...*26 = 26^12 = 9.5429... x 10^16

That's a lot of possibilities!  To put it in spatial dimensions, if 
you observed the 12-letter output of 95 thousand trillion monkeys, 
you would EXPECT that one of the outputs would indeed say 
"haveaniceday."  I say "expect" because there is a tremendous amount 
of room for the "unexpected" in probability.  

To put it in temporal dimensions, let's say that one monkey taps 12 
keys every five seconds.  Therefore, if you observed the typewriter's 
output every time 12 letters came out, you could expect that the 
phrase "haveaniceday" would appear once in (5 * 9.54 x 10^16) 
seconds, or about 15 billion years.  (Hey!  That's how old the 
universe is!  That makes this analogy even better, and I didn't even 
mean for that to happen! I love it!)

Anyhoo, if the monkey taps out 12 letters every five seconds starting 
at the Big Bang, by the present day, you would expect to see the 
phrase "haveaniceday" appear once in that amount of time.

Now, there are no 12-letter Shakespearian works with which I am 
familiar, so it can be seen that the probability is going to 
drastically reduce from its already extremely low value.  If a known 
literary work contains 500,000 characters, the chance of it being 
randomly produced is one in 26^(500,000).  That is incomprehensibly 
small, but NOT ZERO.  This is the key.  No matter how large the 
literary work that you choose, the chances will NEVER be zero.  

Just expand the 12-letter example to the previous example, and you 
will be able to see how at some point far into the future, or 
simultaneously with an extremely large number of typewriters and 
monkeys, or combination of many monkeys AND a point far into the 
future, you can expect to see the chosen literary work appear.  

An extremely vast majority of the outputs will be random and 
incomprehensible because there are more incomprehensible combinations 
of letters than there are sensical combinations.  However, 
mathematics says that one can expect ANY output to appear eventually, 
given a practically unlimited amount of time and resources.

Unfortunately, it cannot be predicted WHEN the work will be produced,
because it is just as likely that the FIRST monkey will do it right
away as it is likely that it will happen in a billion years.  The
example just says that, given enough time, the mathematical field of
probability leads to reason that one can expect to see any familiar
work appear once in that large time frame.

I hope that this will clear things up, at least a little bit.  Please 
feel free to write again if you need further assistance, or if you 
have any other questions.  Thanks for using Dr. Math!

- Doctor Minter, The Math Forum 
Associated Topics:
College Probability
High School Probability

Search the Dr. Math Library:

Find items containing (put spaces between keywords):
Click only once for faster results:

[ Choose "whole words" when searching for a word like age.]

all keywords, in any order at least one, that exact phrase
parts of words whole words

Submit your own question to Dr. Math

[Privacy Policy] [Terms of Use]

Math Forum Home || Math Library || Quick Reference || Math Forum Search

Ask Dr. MathTM
© 1994- The Math Forum at NCTM. All rights reserved.