Monkeys Typing Shakespeare: Infinity TheoryDate: 08/05/98 at 01:26:24 From: adam bridge Subject: Infinity Theory This request is for you to settle an argument within our household if you would be kind enough. Many years ago I read somewhere that if you had an infinite number of monkeys sitting at an infinite number of typewriters for an infinite number of years typing at random then it could be accepted as a probability that one would eventually type the entire works of Shakespeare ! My wife and son say that that this view is incorrect; however, I would appreciate it if you can you shed any light on it from a mathematical viewpoint. Thanking you in anticipation - Adam Bridge Date: 08/13/98 at 13:35:41 From: Doctor Benway Subject: Re: Infinity Theory Hi Adam, So you want the mathematical perspective on the "monkeys typing" scenario? Keep in mind that this is going to be an entirely theoretical answer. As you can imagine, there are some serious practical problems with having an actual infinite number of monkeys typing on an infinite number of typewriters (e.g. where would you put them? what would you feed them?), but since we're mathematicians we can gleefully ignore such considerations. The cheap and easy answer to your question is, "yeah, they'll crank out Shakespeare's works... eventually." This is assuming they really are typing at random. The monkeys with typewriters I have personally observed (mostly of the "young human/little sister" variety) tend to bang on the same keys repeatedly, so it's hard to imagine them actually turning out Shakespeare. But again, this is math so we will ignore the real world. As large as Shakespeare's collected works are, they are still finite. If you type at random, eventually some six-jillion-letter combination you type will end up being the collected works of Shakespeare. An easier way to think about this is picking lottery numbers. Imagine you are filthy rich and decide to buy a bunch of lottery tickets in an effort to win Powerball. Since you are filthy rich, you can afford to buy six jillion lottery tickets with every possible combination of numbers that could come up, and thus you would be guaranteed to win the lottery. It's the same concept with monkeys typing. The grittiest detail in this problem is that the answer is only yes if we are talking about an infinite number of trials; that is, having an infinite number of monkeys or letting one monkey pound away for an infinite amount of time. If we are restricted to a finite number of monkeys and a finite amount of time, then the answer is no. It is entirely possible that in a finite amount of time a finite number of monkeys may type out nothing but pages upon pages of meaningless drivel. It's also possible (although unlikely) that one monkey may get it right the first time. A good way to think of this is to imagine rolling a six-sided die numerous times and waiting for a six to come up. It may come up on the first roll. It's possible that you could keep rolling and rolling millions of times without a six coming up, although you would expect it to come up within six rolls, since there is a 1/6 chance of a 6 turning up on each roll. Let's do an actual example. Since the collected works of Shakespeare are a pretty lofty goal, let's just see about how long we would expect it to take for a monkey to crank out one of Shakespeare's sonnets, for example the following: Look in thy glass and tell the face thou viewest -48 Now is the time that face should form another -45 Whose fresh repair if now thou not renewest -43 Thou dost beguile the world unbless some mother -47 For where is she so fair whose uneard womb -42 Disdains the tillage of thy husbandry -37 Or who is he so fond will be the tomb -37 Of his self love to stop posterity -34 Thou art thy mothers glass and she in thee -42 Calls back the lovely April of her prime -40 So thou through windows of thine age shall see -46 Despite of wrinkles this thy golden time -40 But if thou live rememberd not to be -36 Die single and thine image dies with thee -41 In the above sonnet I removed all punctuation, just leaving the letters and spacing--we can't expect too much; they're only monkeys, right? If my letter count is correct, this leaves 572 letters and spaces. To further simplify, we won't worry about carriage returns, capital letters, or any other such stuff. Anyhow, say we give a monkey a special typewriter that has 27 keys (26 keys for the letters of the alphabet along with a space bar). We let the monkey type 572 characters at a time, pull the sheet out, and see if it's the sonnet. If not, we keep going. We'll do some calculations on the fly here to see how long this process will take. Got a calculator handy? First of all let's find out how many 572-letter possibilities there are for the monkey to type. We have 572 characters, and 27 choices for each character, so there will be 27^572 possibilities (that's 27 times itself 572 times). Punching this into my calculator... er... okay, on second thought better use a computer....I get the following number of possibilities: 5496333784561099393693048531368044344887926194198532520694117049056247 2568424395482058851927075593679213263223991649095444601504350463483987 5025610104140864608504908534119526789608399222986117684072414622768253 6214908304427395812519474546086831288010236639735783766919573127540345 2575089566044810413932116060031762894505524988451285440971813773606694 0163946473467668970711919689863460271936750837609798272198814318196353 5086770723528603185438692855503864007605689811533968043988986405766599 4634626982653271152473969190655534329764726804924235126863461599117918 7453007805890829071114522894672065623217961791812204851353664903930975 3565419938168852881272755213408072890621434530416560019423439471934830 8488558728285338553045399661579902802268940348808763480359167736446637 8909091744053824079947245708112252748079248200721 It's a big number, about 5*10^818. Let's say our monkey can type about 120 characters per minute. Then the monkey will be cranking out one of these about every five minutes, 12 every hour, 288 per day, and 105120 of them per year. Divide that big number by 105120 and you get that it would take that monkey about 5*10^813 years to type out that sonnet. Now say we get 10^813 (that's ten followed by 813 zeros) monkeys working on the job. With that many monkeys working 24 hours a day, typing at random, one of them is likely to crank out the sonnet we are looking for within five years. If the monkeys are particularly unlucky, you may have to let them run an infinite amount of time before they crank out the desired sonnet, but chances are with this many monkeys on the job you will get results in five years. To make a long story short, if you have only a finite number of outcomes and you take an infinite number of trials, you will end up getting the outcome you are looking for. Well, forget about making a long story short, I'll give you one more mind-blowing example. A typical digitized picture on your computer screen is 640 pixels long by 480 pixels wide, for a total of 307200 pixels. Using only 256 different colors, you can get decent resolution. Now if you take 256^307200 (256 times itself 307200 times) you get... well, a pretty big number, but a finite number nonetheless. That's the number of different images you can have of that particular size. Any picture you would scan into a computer at that size and resolution will necessarily be one of those images. Therefore, contained in those images are the images of the faces of every human being who ever lived along with the images of the faces of every person yet to be born. Deep stuff, eh? I'll leave you with that thought. Thanks for writing. - Doctor Benway, The Math Forum http://mathforum.org/dr.math/ |
Search the Dr. Math Library: |
[Privacy Policy] [Terms of Use]
Ask Dr. Math^{TM}
© 1994- The Math Forum at NCTM. All rights reserved.
http://mathforum.org/dr.math/