Free Republic
Browse · Search
News/Activism
Topics · Post Article

Nutters.org

The Mathematics of Monkeys and Shakespeare

or "Monkey Claims Copyright on Hamlet: Film at 11."

A constrained rant by The Famous Brett Watson, 13-Dec-1995.

Introduction

I don't know who it was that first talked about the possibility of monkeys typing randomly on typewriters producing Hamlet entirely by chance, but it is an argument that I have often heard. "Sure it's unlikely," I'm told, "but given enough time and enough monkeys, it would happen."

This argument is actually quite sound -- given enough time and enough monkeys, one could eventually produce "Hamlet" by accident. The fact that it is intuitively sound is the argument's greatest problem, because it means that people generally don't bother checking the exact figures. This is a shame, because it is one of those rare areas of speculation where the exact figures can be calculated.

The other problem is that large numbers are rarely understood. Allow me to tell a little joke to demonstrate.

The Orders of Magnitude Gag

During the US government's "Strategic Defense Initiative" program, better known as "Star Wars", leading scientists on the project were asked to report their progress to the Minister of Defense. So they gathered their data and brought it together in a presentation. In short, they had discovered that the whole problem of shooting down a nuclear missile at such a great distance was a very tricky problem indeed. They intended to explain to the minister what an impossible problem it was -- well beyond the capabilities of current technology. During the course of their presentation, the following exchange took place.

SCIENTIST: ...and so you can see, Mr Minister, that in order to achieve an acceptable hit-rate against the missiles, our instruments need to be accurate to one part in ten to the ninth. So far, the best we have been able to achieve is one part in ten to the fifth.

MINISTER: That's tremendous! We're over half way there!

Our poor politician completely failed to understand the meaning of the scientist's statement. Ten to the fifth is not more than half of ten to the ninth. Ten to the fifth is 100,000 and ten to the ninth is 1,000,000,000. Perhaps our scientist friend would have done better to let the politician see all those zeros -- and then translate it into terms of a budget increase!

This brings me to the question of probability. Just as large numbers are widely misunderstood, there are very few people who appreciate just how unlikely things can be. The monkeys and typewriters scenario sounds possible until you examine the math. What follows is an in-depth discussion of the mathematics of the situation -- it's very long, but interesting, I think.

Monkeys Produce Hamlet: Feasibility Study

Let's imagine a very simple typewriter that has only the 26 upper-case letters, a space bar and five punctuation characters (a total of 32 buttons). It doesn't even have a carriage return -- it does an automatic return when the required number of letters have been typed, and it has an infinite roll of paper being fed through it. We have a monkey that knows how to press the keys and will do so in a totally random manner indefinitely. All in all, we have a little bit of machinery, but no real intelligence in the system. We want our monkey to type the following snippet: "TO BE OR NOT TO BE, THAT IS THE QUESTION."

The probability of this happening is quite simple to calculate, and this will in turn give us some idea of how many monkeys and typewriters we need for a reasonable chance of success. Place your bets now -- our monkeys are fast typists and can type the required number of characters in a single second (there are 41 keystrokes)! On average, how long will it be before one of our monkeys produces a line matching the above sentence?

Well, there are 32 keys, so starting at any moment, the chances of our monkey getting the first keypress right are one in 32. Not good, but we have fast monkeys and lots of time. However, once it has got the first keystroke right, we also need the second keystroke to be right, otherwise we are back to square one. The chances of it getting the first and second keystrokes right are only one in (32*32 = 1024). Only one chance in 1024, but still lots of time to get it right. To get the first three characters right will be a one in (32*32*32 = 32768) chance. Each time it presses a key, there is a one in 32 chance that it will be correct. To get our little snippet of Hamlet, it will need a total of 41 consecutive "correct" keystrokes. This means that the chances are one in 32 to the power of 41. Let's look at a table of values.


   Keys   Chances (one in...)
   ------------------------------------
    1     32
    2     32*32 = 1024
    3     32*32*32 = 32768
    4     32*32*32*32 = 1048576
    5     32^5 = 33554432
    6     32^6 = 1073741824
    7     32^7 = 34359738368
    8     32^8 = 1099511627776
    9     32^9 = 3.518437208883e+013
    10    32^10 = 1.125899906843e+015
    ...
    20    32^20 = 1.267650600228e+030
    ...
    30    32^30 = 1.427247692706e+045
    ...
    41    32^41 = 5.142201741629e+061
    ...
    204   32^204 = 1.123558209289e+307

The last figure is included only because it is the largest value that the MS Windows calculator can handle -- it's doing better than my hand-held Casio (old faithful!) which only goes up to 1e+99. Okay, so these figures are pretty vast, but we have a lot of monkeys and they can type fast. So how long will it take, on average, for one of my monkeys to type a line matching that sentence? Hard question. Let's get an idea of how long we are talking here. How many lines can my monkey type in a year, given that it types at a rate of one line per second?


  1 line per second
  * 60 seconds per minute = 60 lines per minute
  * 60 minutes per hour = 3600 lines per hour
  * 24 hours per day = 86400 lines per day
  * 365.24 days per year = 31556736 lines per year

Okay, now for the moment of truth. We know how many possible different lines can be produced, hence how likely it is for us to get the right one at random (because only one is right). We can calculate the chances of getting the quote in a year most easily by calculating the chances of missing on every attempt: the chances of getting the quote will be 100% minus the chances of missing on every attempt. I need a really amazingly precise calculator to do this because the chances of missing are so close to 100% that most calculators will round it off to 100%. The calculation is as follows.


 probability of missing on one attempt = 1 - 1/(32^41)
 ...of missing for a minute straight = (1 - 1/(32^41)) ^ 60
 ...of missing for an hour straight = ((1 - 1/(32^41)) ^ 60) ^ 60
 ...of missing for a day straight = (((1 - 1/(32^41)) ^ 60) ^ 60) ^ 24
 ...for a year straight = ((((1 - 1/(32^41)) ^ 60) ^ 60) ^ 24) ^ 365

If you have access to Unix, you can calculate this with the dc command, but be warned that it may take quite a while to calculate and annoy other users because the computer is so slow. Use of the nice command is suggested. The syntax, should you care to try, is as follows. Type the dc command, then type the following lines.


  99k
  1 1 32 41 ^ / - 60 ^ 60 ^ 24 ^ 365 ^
  p

The figure that is eventually printed will be the probability (expressed as a value between zero and one) of our monkey not typing our little phrase from Hamlet in the space of one year's worth of continuous attempts. The answer that it prints looks like this:

0.999999999999999999999999999999999999999999999999999999386721844366784484760952487499968756116464000

Notice all the nines? Even to fifty or more significant figures, this reads 100%. Okay, so realistically, there is no way that our monkey can do its job in a year. Maybe we should start talking centuries? Millenia? As I understand it, common scientific wisdom suggests that the universe is about 15 billion years old (although they may have revised their dating since I last heard about it). We can easily extend our current figure of one year to count many years. Our calculator will be much faster if we break the calculation down to powers of two and just use the "square" operation, so let's choose a nice even power of two like 2^34, which is about 17 billion (17,179,869,184 to be precise). The new figure is:

0.999999999999999999999999999999999999999999989463961512816564762914005246488858434168051444149065728

The chances of failure are still essentially 100%, even after 2^34 years. Hmmm. It doesn't look like were are going to get very far with this, but just for the heck of it, let's see if we are any better off with a lot of monkeys. Let's not hold back here -- I hypothesize 17 billion galaxies, each containing 17 billion habitable planets, each planet with 17 billion monkeys each typing away and producing one line per second for 17 billion years. What are the chances of the phrase "TO BE OR NOT TO BE, THAT IS THE QUESTION." not being included in the output?

0.999999999999946575937950778196079485682838665648264132188104299326596142975867879656916416973433628

I'd bet money on that. It's about 99.999999999995% sure that they would fail to produce the sentence. Are you astounded? It's such a trivial requirement, right? Just one puny sentence. And yet the figures keep coming up "impossible". Where have we made a mistake? We have fallen into the same trap as the politician who was the subject of my joke, way back up there. We have failed to appreciate the sheer magnitude of the problem. Let's look at it one more time.

The number of 41-character strings that are possible with a 32-character alphabet is 32^41. According to dc, this value is as follows.

51422017416287688817342786954917203280710495801049370729644032

In case you don't feel like counting, this value is 62 digits long. In our hypothesising above, we imagined 17 billion galaxies, each with 17 billion planets, each with 17 billion monkeys, each of which was producing a line of text per second for 17 billion years. How many lines of text did we wind up producing in this experiment? The math is as follows:

2^34 * 2^34 * 2^34 * 2^34 * 365 * 24 * 60 * 60

And the answer is as follows:

2747173049143991138247931294711870033017962496000

Once again, in case you don't feel like counting, the answer is 49 digits long. Now, there is no guarantee that our monkeys are going to type something different every time, but even if we managed to rig up the experiment so that they never tried the same thing twice, they have still only produced 1/18,718,157,355,362 of the possible alternatives. The denominator in that fraction is 14 digits long, by the way. It's a figure that's vastly bigger than anything you would come across in the real world. Is it any wonder, in light of that, that it is so damn hard to get the right answer by accident?

Conclusion

In light of this, I find it impossible to believe that "chance" had anything to do with the process that created life. How can I suppose that Shakespeare himself was the result of a random process when it is quite clearly impossible for even a trivial fragment of his work to have arisen by chance? No sir, I see information all around me, and I conclude that it is the product of a far, far greater intelligence.

Information is the product of intelligence, not chance.

Postscript

If you read the thesis above, you will agree at least that if the universe did arise by chance, it must be truly infinite and in the continuous process of trying out new alternatives. That, and the universe as we know it is an incomprhensibly unlikely fluke. I find it much simpler (and much more "natural", I might say) to suppose that there is a God who is greater than the universe who made it, much like I made this document.

Comments on this article are welcome.

See Also

More Monkey Business
A followup to this essay by the same author, dated 2000-07-28. Gives mathematical insights into other monkey math problems and answers questions frequently raised in regards to this essay.

Nutters.org Author: The Famous Brett Watson <famous@nutters.org>
History: [1995-12-13] Written as an email to Peter Lowe.
History: [1996-01-09] Converted to HTML 2.0 with minor alterations.
History: [1998-10-16] Corrected contact info.
History: [2000-08-15] Updated to HTML 4.0 with cosmetic changes. Added link to "More Monkey Business".
IPRs: This document is Public Domain (P) 1995.
Acknowledgements: the author wishes to acknowledge Peter Lowe as the person who inspired this essay.

1 posted on 03/05/2002 12:52:58 PM PST by Southack
[ Post Reply | Private Reply | View Replies ]


Navigation: use the links below to view more comments.
first previous 1-2021-4041-42 next last
To: Southack
bump
52 posted on 03/05/2002 1:56:16 PM PST by azhenfud
[ Post Reply | Private Reply | To 1 | View Replies ]

To: Southack
What was the mathematical probability of William Shakespeare writing the works of William Shakespeare?
59 posted on 03/05/2002 2:06:39 PM PST by Harrison Bergeron
[ Post Reply | Private Reply | To 1 | View Replies ]

To: Southack
I have found that believers in evolution HATE numbers. Trying to pin them down about testable numbers is a very frustrating exercise. This helps explain why most of their replies to your post have been efforts to change the subject or personal insults.

For the ones who say "but it is an INFINITE amount of monkies" I say, but you do not have an INFINITE amount of time to work with, nor an infinite amount of matter. The universe, as incrediably vast as it is, is FAR to brief and tiny for life to have arisen by chance. You DO NOT have an infinite number to work with. The numbers you have are huge, but are as nothing compared to the scope of the problem.

As for the crowd who insists "but it is not random, their are rules", I say this- If rules, then a Rulemaker. And if the Rules say that new Phylums, classes, orders and families can arise by chance, then we should be able to create new versions of these things BY generating those chances (inducing mutations under (intelligent in this case) selection pressure). We can't, so if there are rules, one of them seems to be that their are limits to the amount of change that can be produced by chance mutations and selctions pressures.

62 posted on 03/05/2002 2:09:00 PM PST by Ahban
[ Post Reply | Private Reply | To 1 | View Replies ]

To: Southack
Dr. Walter Martin put it concisely when he stated "What chance creates, it almost immediately destroys." Whether or not he was, in turn quoting someone else, I'm not certain.
77 posted on 03/05/2002 2:28:22 PM PST by william clark
[ Post Reply | Private Reply | To 1 | View Replies ]

To: Southack
In light of this, I find it impossible to believe that "chance" had anything to do with the process that created life.

Keep in mind also that if life arose by chance on earth, the chances that it arose anywhere else is the square of the chance that it arose by chance on earth. The chance that intelligent life arose in 1000 different systems throughout the universe is the chance that it arose by chance on earth raised to the 1000 power. Of course, people have realized for a long time that chance isn't going to work. Besides chance, you need a mechanism, the operational output of which is measured in terms of chance. Chance can't bring a mechanism into being any more than accounting can cause money to come to exist in a bank (C. S. Lewis made a similar point in Miracles when he said that "the laws of nature" can't be appealed to as the cause of nature because you have to have nature first before you can have anything such as natural laws). Because of these insurmountable difficulties there have been two main approaches to solving the problem. One approach is the leap of faith approach and to say, as Julian Huxley did, that the appearance and development of life on earth through evolutionary means is clearly impossible but that the only alternative, special creation, is unthinkable. This is also seen in the "It must have happened because we are here" so-called argument. The other approach is the other leap of faith approach and to say that since it is impossible for life to have arisen on Earth by chance (much less anywhere else) that spontaneous generation followed by evolution of life is an inherent property in the universe and, therefore, is quite likely. There is a significant percentage of people, though, who keep on with the monkey-typing-Shakespeare myth.
86 posted on 03/05/2002 2:39:48 PM PST by aruanan
[ Post Reply | Private Reply | To 1 | View Replies ]

To: Southack
Does this mean the Earth is still flat and the Universe revolves around it on a crystal sphere?

Sorry, but scientific observation has proved that evolution occurs. It just disagrees upon the mechanism of that evolution. But extensive sedimentary layers with a fossil record that starts with the simplest organisms and with time (layers=time) more and more advanced forms appear points towards some form evolutionary change.

Of course, you could argue that the MIND that created the Universe. GOD. Neglected to give IT's ultimate creation, life the ability to physically adapt to changing environmental conditions.

180 posted on 03/05/2002 5:45:16 PM PST by Archaeus
[ Post Reply | Private Reply | To 1 | View Replies ]

To: Southack
First of all, the monkeys have to be infinite. That's already been said by other posters. If that's the case, the monkeys will produce - eventually - every work.

So, let's say the universe is infinite as well. Couldn't it be the case that we're the Shakespearean work among trillions of planets full of garbage? Certainly possible.
192 posted on 03/05/2002 7:05:36 PM PST by July 4th
[ Post Reply | Private Reply | To 1 | View Replies ]

To: Southack
Sounds like the Million Monkey March is coming to town!
205 posted on 03/05/2002 8:05:20 PM PST by Tolerance Sucks Rocks
[ Post Reply | Private Reply | To 1 | View Replies ]

To: Southack
The probabilistic arguments against evolutionism boil down to this. Every single kind of complex creature which has ever walked, flown, swam, crawled, or slithered on the face of this Earth would require beating near-infinite odds to have evolved; the probability is a 10'th - 20'th order infinitessimal. Now, a reasonable person might could at least listen to a theory which demanded one or two probabilistic miracles in the entire history of the Earth, but a theory which demands an essentially infinite series of such violations of probabilistic laws, i.e. one such probabilistic miracle for every kind of creature, living and extinct, is clearly beyond the pale. That stands everything we know about mathematics and probability on its head.
220 posted on 03/05/2002 9:05:17 PM PST by medved
[ Post Reply | Private Reply | To 1 | View Replies ]

To: Southack
bump
237 posted on 03/06/2002 4:56:05 AM PST by Sgt_Schultze
[ Post Reply | Private Reply | To 1 | View Replies ]

To: Southack
If you believe in God, and you recognize all the facts which prove evolution as a biological mechanism, then it is obvious that "chance" is at times subject to Divine Intervention.
265 posted on 03/06/2002 12:53:05 PM PST by ZULU
[ Post Reply | Private Reply | To 1 | View Replies ]

To: Southack
To everyone on this forum,

I have been posting replies to these types of threads for almost three years. Last year I finally gave up. Nothing will ever convince the creationist crowd that they are scientifically incorrect. They don't believe in the scientific method. They don't understand that the articles they post are missing the point. They really don't understand natural selection and they never will. The majority of them are blissfully ignorant of chemistry, biology, geography, astronomy, and genetics. They will reject any information which is contrary to their world view.

Trust me, your brilliant insight is wasted upon this crowd. They will not listen. They will continue to lie unconsciencely beneath the ocean of dogma they consider the truth.

289 posted on 03/06/2002 5:15:14 PM PST by Western Patriot
[ Post Reply | Private Reply | To 1 | View Replies ]

To: Southack
See The Library of Babel, by Jorge Luis Borges.

I also commend to Freepers his excellent short stories The Zahir and The Aleph.

Probably the best writer to come from South America in the 20th century.

--Boris

307 posted on 03/06/2002 7:35:03 PM PST by boris
[ Post Reply | Private Reply | To 1 | View Replies ]

To: Southack
What a great article! Thanks for posting it. The follow-up article is also fascinating.
312 posted on 03/06/2002 8:14:03 PM PST by monkeyshine
[ Post Reply | Private Reply | To 1 | View Replies ]

To: Southack
"DNA will self-form given enough time" or even that a million monkeys typing randomly on a million keyboards for a million years will eventually produce the collected works of Shakespeare.

I heard that it was approximately the same probability as the Encylopoedia Britanica being produced by an explosion in a print shop!

453 posted on 12/09/2002 11:57:07 AM PST by nightdriver
[ Post Reply | Private Reply | To 1 | View Replies ]

To: Southack
..or even that a million monkeys typing randomly on a million keyboards for a million years will eventually produce the collected works of Shakespeare.

Hasn't AOL proven the fallacy of that argument?

470 posted on 12/09/2002 1:05:04 PM PST by TC Rider
[ Post Reply | Private Reply | To 1 | View Replies ]

To: Southack
Great article! It is easy to understand. Don't let your critics get you down. Most evolutionists that I have known cannot accept that there may be a being (God) with an intelligence far above their own. To admit that they were created by a higher power is just too much for them to swallow -- hence they do their very best to explain the existance of life on this planet.

I haven't yet heard an explanation from them on where the stuff was before the "Big Bang". In addition to the existance of material things, I have yet to hear an explanation of the origin of such things as human emotion, instinct, etc. Is is obvious that we are insignificant compared to the vastness of our creator - but the evolutionists will have to wait until the end of time to find out the truth.

491 posted on 12/09/2002 3:13:55 PM PST by Retiredforever
[ Post Reply | Private Reply | To 1 | View Replies ]

To: Southack
How silly. God already told us how He made man.
540 posted on 12/09/2002 7:00:20 PM PST by greggy
[ Post Reply | Private Reply | To 1 | View Replies ]

To: Southack
Bump
671 posted on 12/12/2002 9:40:17 AM PST by Fiddlstix
[ Post Reply | Private Reply | To 1 | View Replies ]

To: Southack
"I hypothesize 17 billion galaxies, each containing 17 billion habitable planets, each planet with 17 billion monkeys each typing away and producing one line per second for 17 billion years. What are the chances of the phrase "TO BE OR NOT TO BE, THAT IS THE QUESTION." not being included in the output?

0.999999999999946575937950778196079485682838665648264132188104299326596142975867879656916416973433628

I'd bet money on that. It's about 99.999999999995% sure that they would fail to produce the sentence."

17 billion galaxies x 17 billion habitable planets x 17 billion monkeys at one line per second x 17 billion years (or 365.25 * 24 * 60 * 60) = 2.6357223096 x 10^48.

If the failure rate is 99.999999999995%, then the success rate is 0.000000000005%.

In those 17 billion years, the line will be created (2.6357223096 x 10^48)(0.000000000005) = 1.3178611548 x 10^37 times = 13,178,611,548,000,000,000,000,000,000,000,000,000 times = umpteen gazillion times.

I think that either I or the author of this thread has made a mistake, because I do not understand how the laws of probability would allow that many successful lines of text, if "... they have still only produced 1/18,718,157,355,362 of the possible..." lines of text.

685 posted on 08/31/2003 11:53:20 AM PDT by Voice in your head ("The secret of Happiness is Freedom, and the secret of Freedom, Courage." - Thucydides)
[ Post Reply | Private Reply | To 1 | View Replies ]


Navigation: use the links below to view more comments.
first previous 1-2021-4041-42 next last

Free Republic
Browse · Search
News/Activism
Topics · Post Article


FreeRepublic, LLC, PO BOX 9771, FRESNO, CA 93794
FreeRepublic.com is powered by software copyright 2000-2008 John Robinson