Infinite Monkey Theorem

Syed Saad Ahmed
3 min readFeb 17, 2018

--

The Infinite monkey hypothesis expresses that a monkey hitting keys aimlessly on a console for an infinite measure of time will without a doubt compose a given content, for example, the total works of William Shakespeare.

A monkey with a typrwriter

Suppose the typewriter has 50 keys, and the word to be typed is banana. If the keys are pressed randomly and independently, it means that each key has an equal chance of being pressed. Then, the chance that the first letter typed is ‘b’ is 1/50, and the chance that the second letter typed is a is also 1/50, and so on. Therefore, the chance of the first six letters spelling banana is

(1/50) × (1/50) × (1/50) × (1/50) × (1/50) × (1/50) = (1/50)^6 = 1/15 625 000 000 ,

less than one in 15 billion, but not zero, hence a possible outcome.

From the above, the chance of not typing banana in a given block of 6 letters is 1 − (1/50)^6. Because each block is typed independently, the chance Xn of not typing banana in any of the first n blocks of 6 letters is

Probability Equation

As n grows, Xn gets smaller. For an n of a million, Xn is roughly 0.9999, but for an n of 10 billion Xn is roughly 0.53 and for an n of 100 billion it is roughly 0.0017. As n approaches infinity, the probability Xn approaches zero; that is, by making n large enough, Xn can be made as small as is desired, and the chance of typing banana approaches 100%.

The same argument shows why at least one of infinitely many monkeys will produce a text as quickly as it would be produced by a perfectly accurate human typist copying it from the original. In this case
Xn = (1 − (1/50)^6)^n where Xn represents the probability that none of the first n monkeys types banana correctly on their first try. When we consider 100 billion monkeys, the probability falls to 0.17%, and as the number of monkeys n increases, the value of Xn — the probability of the monkeys failing to reproduce the given text — approaches zero arbitrarily closely. The limit, for n going to infinity, is zero. So the probability of the word banana appearing at some point in an infinite sequence of keystrokes is equal to one.

REAL EXPERIMENT

In 2003, people from the University of Plymouth introduced a work station in a monkey cage at the Paignton Zoo in Britain with a gathering of six macaque monkeys, giving the monkeys a decent strong month or so to blast out some spec contents. The whole setup was observed so analysts could watch the Infinite Monkey thought become animated before them.

So what happened? What did the monkeys produce?

The monkeys create nothing as well as five aggregate pages, to a great extent comprising of the letter S, the lead male started by bashing the console with a stone, and the monkeys proceeded by urinating and crapping on it.

However there are many simulators that ask you for a random word and then start hitting the random characters just to produce the occurrence of your typed word, for example refer code pen for that (https://codepen.io/justinchan/full/enBFA)

Geoff Cox, head of the project, is more realistic:

“It was a hopeless failure in terms of science but that’s not really the point,” said Geoff Cox ,of Plymouth University’s MediaLab, who designed the test. So what were the academics trying to achieve? “It wasn’t actually an experiment as such, it was more like a little performance,” said Mr Cox. “The monkeys aren’t reducible to a random process. They get bored and they shit on the keyboard rather than type.”

--

--

Syed Saad Ahmed
Syed Saad Ahmed

Written by Syed Saad Ahmed

Python, DevOps, Cryptography, Infrastructure Automation. https://thesaadahmed.com/

Responses (1)