TOPICS
Search

Infinite Monkey Theorem


The infinite monkey theorem states that a monkey pressing typewriter keys independently at random for an infinite amount of time will almost surely type any prescribed finite string of characters, and will in fact type it infinitely many times (Tassion 2025). More precisely, let X_1,X_2,... be independent and identically distributed random variables taking values in a finite alphabet A containing at least two symbols, with P(X_n=a)=p_a>0 for every a in A. For a fixed string w=w_1...w_m, the probability that one prescribed block of m symbols equals w is

 q=product_(j=1)^mp_(w_j)>0.

The events that w occurs in successive disjoint blocks of length m are independent, so the probability that it occurs in none of the first N such blocks is (1-q)^N, and

 lim_(N->infty)(1-q)^N=0.

Equivalently, the second Borel-Cantelli lemma shows that w occurs infinitely often almost surely. Since the collection of finite strings over a finite alphabet is countable, with probability one every such string occurs infinitely often.

The statement concerns probability one, not logical certainty. For example, the possible infinite output consisting of a single symbol repeated forever contains most strings zero times, but that output has probability zero. The theorem is related to normal numbers, but is weaker: a normal number has the correct limiting frequency for every finite digit block, whereas mere occurrence of every finite block imposes no such frequencies. The typing-monkey metaphor goes back at least to Borel (1913) and continues to be used to illustrate the cumulative effect of rare random events (Big Think 2026).

Banerji et al. (2014) gave a graph-theoretic analog. In the sequential random construction defining graph likelihood, every finite graph can be constructed and therefore has positive likelihood.


See also

Almost Surely, Borel-Cantelli Lemma, Independent and Identically Distributed, Graph Likelihood, Normal Number, String

Explore with Wolfram|Alpha

References

Banerji, C. R. S.; Mansour, T.; and Severini, S. "A Notion of Graph Likelihood and an Infinite Monkey Theorem." J. Phys. A: Math. Theor. 47, 035101 (8 pp.), 2014. https://doi.org/10.1088/1751-8113/47/3/035101.Big Think. "One of the World's Greatest Mathematicians Explains 6 Essential Concepts of Math." Featuring T. Tao. 2026. https://www.youtube.com/watch?v=OOMx2BHHWtE.Borel, E. "Mécanique Statistique et Irréversibilité." J. Phys. Théor. Appl. 3, 189-196, 1913. https://doi.org/10.1051/jphystap:019130030018900.Tassion, V. "The Infinite Monkey Theorem." §3.4 in Probability Theory. Zürich, Switzerland: ETH Zürich, pp. 41-42, 2025. https://metaphor.ethz.ch/x/2025/hs/401-3601-00L/mainappendix.pdf.

Cite this as:

Weisstein, Eric W. "Infinite Monkey Theorem." From MathWorld--A Wolfram Resource. https://mathworld.wolfram.com/InfiniteMonkeyTheorem.html

Subject classifications