CLICK HERE FOR THOUSANDS OF FREE BLOGGER TEMPLATES »

Wednesday, September 19, 2007

The Infinite Monkey Theorem

A few weeks back, I was listening to Good Times with Mo (more on this on a later post) and the radio jocks were on the topic of luck. The main jock, Mo Twister, said he didn't believe in luck and that things happen just because all factors involved were properly aligned. He added that given an infinite number of tries, you'll be able to succeed in any situation - the lottery for example. With this statement, one of the other jocks - Mojo Jojo - disagreed and said that given an infinite number of tries wouldn't eventually result in a success but would only raise the probability of success. They continued to argue with Mojo screaming that he hoped a Math professor would call to back him up.

My elder brother of only a year is a finished BS Mathematics and is currently teaching Math in the same university where he graduated - the University of the Philippines. I brought up the story I narrated above and he had an interesting answer. He said Mo Twister was right! So ok, if a Math professor did call the radio show that morning, Mojo would've been placed in a deeper hole. So what exactly did my brother say that supports Mo Twister's side? The Infinite Monkey Theorem! At first I couldn't believe it, come on, it had a funny, unbelievable and not so credible name. Here's what my brother showed me - it's funny but interestingly true! And hey, it makes a lot of sense.

The infinite monkey theorem states that a monkey hitting keys at random on a typewriter keyboard for an infinite amount of time will almost surely type a particular chosen text, such as the complete works of William Shakespeare (my brother mentioned typing the Bible for his example). In this context, "almost surely" is a mathematical term with a precise meaning, and the "monkey" is not an actual monkey; rather, it is a metaphor for an abstract device that produces a random sequence of letters ad infinitum. The theorem illustrates the perils of reasoning about infinity by imagining a vast but finite number, and vice versa. The probability of a monkey typing a given string of text as long as, say, Hamlet is so infinitesimally tiny that, were the experiment conducted, the chance of it actually occurring during a span of time of the order of the age of the universe is minuscule but not zero. In mid-2003, researchers at Plymouth Univesity in England actually put a working computer in a cage with six crested macaques. The monkeys proceeded to bash the machine with a rock, urinate on it, and type the letter S a lot (later, the letters A, J, L, and M also crept in). The results were published in a limited-edition book, Notes Towards The Complete Works of Shakespeare. A researcher reported: “They were quite interested in the screen, and they saw that when they typed a letter, something happened. There was a level of intention there.

The key to this theorem is the fact we are dealing with infinity. This is very difficult to grasp or accept since infinity exists only as an idea or concept and it isn't bounded. Take the largest number you can think of and that would still be nothing compared to infinity. Think about it, you can always keep on adding 1 to the largest you can come up with and even that would be minuscule to infinity. Now, I leave you with a letter from Ask Dr. Math which tries to explain the concept of the theorem and the importance of (at least) trying to understand the idea of infinity. Sorry Mojo! Thanks Kuya Chuck! As Buzz Lightyear would say, "To infinity, and beyond!"

===================
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:

549633378456109939369304853136804434488792619419853252069411
704905624725684243954820588519270755936792132632239916490954
44601504350463483987502561010414086460850490853411952678960
839922298611768407241462276825362149083044273958125194745460
868312880102366397357837669195731275403452575089566044810413
932116060031762894505524988451285440971813773606694016394647
3467668970711919689863460271936750837609798272198814318196353
508677072352860318543869285550386400760568981153396804398898
6405766599463462698265327115247396919065553432976472680492423
51268634615991179187453007805890829071114522894672065623217961
7918122048513536649039309753565419938168852881272755213408072
890621434530416560019423439471934830848855872828533855304539
966157990280226894034880876348035916773644663789090917440538
24079947245708112252748079248200721

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

0 comments: