Index / Chance
Infinite Monkey Theorem
A room of monkeys hitting keys at random will eventually type any given text. This works out how long “eventually” is, exactly, on digit strings, and prints every digit of it.
The text
Characters the keyboard below does not have are
dropped, and the page says which.
The monkeys
An empty box is one monkey.
Five a second is faster than a person types and
is being generous to the monkeys.
Expected wait
--
Characters used
--
Chance per attempt
--
Every digit of it
For comparison
things that are also large
The model, the arithmetic, and the one part everybody gets wrong
Every keystroke is independent and every key equally likely.
That is the model, and it is the only reason any of this is calculable.
Real monkeys are not random generators: when Paignton Zoo put a keyboard
in with six crested macaques in 2003 the result was five pages
consisting largely of the letter S, after which they used the keyboard
as a toilet.
The chance of a given attempt being right is 1 in kn, for k keys and n characters. That part is easy. The part that is usually wrong is the wait.
The expected wait is not kn keystrokes unless the phrase cannot overlap itself. Keystrokes come in one continuous stream, so attempts share letters and are not independent trials. The correct expected number of keystrokes is the sum of kL over every length L for which the first L characters equal the last L — Conway's leading number. For a phrase with no self-overlap that sum is just kn. For abab it is k4 + k2, because a run can end two characters into the next attempt. The overlap terms are printed below whenever they are not zero.
The arithmetic is exact and done on digit strings. kn for a phrase of any length passes what a double can count long before it gets interesting, so every power, product and division here is long multiplication and long division on decimal digits, the way it is done on paper. Divisions are floored, and the page says so where it matters.
Nothing is written in scientific notation. That is the whole point of the tool: 1047 is not a number anyone can feel, and a hundred thousand digits of one is.
A year is the Julian year, 365.25 days, 31,557,600 seconds. The age of the universe is taken as 13.787 billion years, the Planck 2018 figure. The observable universe is taken to hold about 1080 atoms, which is an order of magnitude, not a measurement.
The theorem is about infinite time, and infinity is doing all the work. The probability of typing the phrase eventually is exactly 1; the probability of typing it before the universe becomes uninhabitable is, for anything longer than a few words, indistinguishable from zero. A 2024 paper by Woodcock and Falletta made exactly this point: with the resources actually available, the monkeys do not get there.
The chance of a given attempt being right is 1 in kn, for k keys and n characters. That part is easy. The part that is usually wrong is the wait.
The expected wait is not kn keystrokes unless the phrase cannot overlap itself. Keystrokes come in one continuous stream, so attempts share letters and are not independent trials. The correct expected number of keystrokes is the sum of kL over every length L for which the first L characters equal the last L — Conway's leading number. For a phrase with no self-overlap that sum is just kn. For abab it is k4 + k2, because a run can end two characters into the next attempt. The overlap terms are printed below whenever they are not zero.
The arithmetic is exact and done on digit strings. kn for a phrase of any length passes what a double can count long before it gets interesting, so every power, product and division here is long multiplication and long division on decimal digits, the way it is done on paper. Divisions are floored, and the page says so where it matters.
Nothing is written in scientific notation. That is the whole point of the tool: 1047 is not a number anyone can feel, and a hundred thousand digits of one is.
A year is the Julian year, 365.25 days, 31,557,600 seconds. The age of the universe is taken as 13.787 billion years, the Planck 2018 figure. The observable universe is taken to hold about 1080 atoms, which is an order of magnitude, not a measurement.
The theorem is about infinite time, and infinity is doing all the work. The probability of typing the phrase eventually is exactly 1; the probability of typing it before the universe becomes uninhabitable is, for anything longer than a few words, indistinguishable from zero. A 2024 paper by Woodcock and Falletta made exactly this point: with the resources actually available, the monkeys do not get there.