ML: Monte Carlo Methods


Conducting physical experiments to validate probabilistic models is not always justified. A reasonable alternative is numerical experiments. Unfortunately, all programming languages use somewhat "biased" random number generators. However, in most cases, they are sufficient.

Variance of event frequency

Let's verify the previously derived formula for the variance of the probability of an event, which is obtained from $N$ observations. To do this, we will conduct $N_{exp}$ numerical experiments, in each of which we will simulate the occurrence of some event $A$ $N$ times with probability $p_A$. We will compute the variance of the empirical probability based on these experiments. Below is the corresponding code.