### Going Back to the Monkey Typewriter Problem

#### by Mithrandir

I began this blog with two articles on the Monkey Typewriter Theorem and, in the last one, I’ve said that there should be a possibility to stop the Monte Carlo simulation at exactly the needed point (when the required precision has been attained).

Truth is there may be at least one method to do this.

Let’s suppose that our simulation is made in order to obtain a single real value (the theory presented here can be extrapolated to the multidimensional case with a little pain and some tricks but it works). We will consider the Monte Carlo simulation as a process in which we experimentally measure a natural measure.

Suppose we name the result of the i-th measurement . We’ll note the real value (the one we cannot obtain) and we will take

to be the average of the n computations (n runs of the Monte Carlo simulation). By the Law of Large Numbers (the same law that stays behind the Monte Carlo simulation) we can be certain that, with a high probability

where and are strongly related to each other. In fact, is uniformly distributed in this interval with a pdf of constant value . By integrating this pdf we obtain

from which one can obtain the value.

Now, let’s turn our attention to a concept known as the information entropy. We will use this concept to obtain a relation which will enable us to stop from making further simulations. By using it’s general definition, we have

By taking into account the formula for above, we obtain

which turns out to be something similar to what we were looking for (in the last line I’ve changed the notations a little, without changing the names and the meanings, only to show that what we have obtained depends strongly on the number of measurements we have undertaken). In fact, by turning our attention to the (apparent) information we obtained in the last measurement

we see that, because and , our last result is **always positive and decreasing.**

Thus, if someone would be able to deduce a relationship between the precision of the measurement and the value of , we could stop the Monte Carlo process earlier or decide – algorithmically, thus eliminating any need for human intervention – to continue for another 1000 (random value) runs.

However, there’s a glitch: one single malformed data will affect our computation too badly. Thus, we need something to eliminate any outliers from the early stages of computation.

And we need some code results.