7Pseudorandom Numbers and Monte Carlo Simulations
Random Numbers and Simulations
Suppose we want to generate a list of uniformly distributed random numbers. These could be integers between 0 and 10, or real numbers between .0 and 1.0, or some other requirement. We want to do this because it allows us to write computer programs that perform Monte Carlo Simulations. A Monte Carlo simulation lets us perform a simulation of any situation involving random numbers that we can describe clearly, and look at possible results. If we repeat this process many times, then we get to see the statistical variations in these results. As a simple example, let's look at our simple coin flip again. If we had a list of randomly generated zeros and ones, then we could assign the zero to a coin flip heads and a one to a coin flip tails. By counting the number of zeros and ones and looking at the ratio, we could conclude that the probabilities of heads and tails is .5 each. If we looked at, say 1 million lists of zeros and ones, each list containing 100s of these numbers, then we could calculate the standard deviation we'd expect in a 100 coin flip game. While in this simple scenario we know how to calculate all of these things and don't need a simulation, there are an infinite number of complicated situations where we cannot calculate and predict the results – and then a simulation is a powerful tool.
Pseudorandom Numbers
Hardware random number generators are machines that measure random noise ...
Get Probably Not, 2nd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.