Gadget: Infinite Monkey

The Infinite Monkey Theorem [IMT] states that a sufficiently-large number of monkeys, randomly hitting keys on typewriters, will eventually reproduce the works of Shakespeare. It’s an “order hidden in chaos” claim as old as history. Let’s ignore the problems with using monkeys (ie: intelligence, low output, boredom, etc).

Mathematically, the IMT relies on the monkeys providing a random string of characters. The likelihood of a given string corresponding to a known text (ie: Shakespeare) is very, very small — but not infinitesimal. Thus, if you wait long enough, the probability will grow until you can be reasonably confident a certain string will be produced (however, after no amount of time can you be 100% sure — just as after no number of coin flips can you be completely sure you’ve gotten at least one tail).

What I find interesting, and overlooked by most people who hear about the IMT, is how quickly the numbers grow. To bring these issues to light, I used an Arduino and an 8×8 LED matrix to simulate a monkey. 5 times per second, a letter is randomly chosen and drawn. If the string of letters matches the string “TOBEORNOTTOBE” (“to be or not to be”, the display pauses and green LEDs at the bottom of the display indicate the number of letters in the string that match.

2014-01-03 10.47.57

In the above image, the letter T has just appeared, and the single green LED signals that there is a one-letter match. You’d need to wait an one hour (on average) in order to see the string “TOB”, and about a day (on average) to see “TOBE”.

The 19-character string, “TOBEORNOTTOBE” will come along on average once every 10 000 million million years, or a million times longer than the age of the universe.

The full text of Hamlet will take a bit longer.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s