top of page
Writer's pictureAnthony Mudhoka

Coming up Soon...Infinite Monkey Theorem with Python

Once upon a time in a place far beyond our own galaxy, a poor monkey was locked inside a room with a typewriter. His only instructions were to keep hitting the keys of the typewriter for eternity. He typed away day and night, hitting keys at random, until he lost all sense of time. Civilizations were born, grew, died and forgotten yet the poor monkey kept typing nonstop. He typed through the birth and death of stars, the extinction of the dinosaurs, rise of the mammals and evolution of the primates. Suddenly on one day, the monkey was released. He had fully served his sentence. After eons of randomly typing, he came up with a perfectly typed merchant of Venice by William Shakespeare.



This is called the Infinite Monkey Theorem. It states that there is a non zero probability that a monkey typing randomly on a typewriter will eventually type any given text in existence given infinite time. This is a philosophical discussion which stems from the fact that in a probability sample space with statistically independent events with probabilities P = {a,b,c,d,e,f,g...} then the probability P of all the events occurring is P = a * b * c * d * e * f * g... as the sample space gets larger and larger with events with probabilities less than 1, the joint probability converges to zero. Intuitively it is harder to roll two 6s in a row than just 1.

Just to give you an idea the probability of hitting 1 letter at random from 26 keys is 1/26. Now if we wanted to type "THEMATHLAB" at random we would require a luck of 1 in 141,167,095,653,376.

If it took us 1 second to hit a letter , then it would take us an average of 4.4 million years to to get the name of this blog page!!!!


Stay tuned for the full blog coming up soon to learn more about the fate of the monkey and the infinite typewriter!!!

Comments


3a5c95dbd9b683a6695aed1241c6db9d.png
bottom of page