The concept of the Monte Carlo simulation originated from Polish-American mathematician Stanislaw Ulam, who, apart from his love of thermonuclear weapons, was a big fan of solitaire. He spent a lot of time playing the game while recovering from an illness, and sought a way to predict his chance of winning using combinatorics. Despite being an incredible mathematician, he failed to do so.
Ulam then supposed that instead of calculating a probability, he would just try playing a few hands, count the number of hands he won, then divide by the number of games played. He realized, however, that it might take him a very long time to win even a single game, so he turned to his friend John von Neumann to help him simulate them instead. von Neumann used his new ENIAC to simulate multiple games of solitaire within a few hours of computation, a task that would take microseconds today.
Formally, the Monte Carlo simulation is a method of estimating the value of an unknown quantity using the principles of inferential statistics. It involves making predictions about a population, or a set of examples, using information about a sample, or a proper subset of the population. In the solitaire example, the population is the set of all possible games of solitaire - a very large set - and the sample is the set of simulated games done by the computer. The key fact that Monte Carlo simulations rely upon is that if one chooses a sample at random, it tends to exhibit the same properties as the population from which it is drawn.
There are many applications to the Monte Carlo simulation, belonging to fields like computational biology, fluid dynamics, and even computer graphics. The following section visualizes an example of using a simulation to estimate the value of pi.
Estimation of Pi using a Monte Carlo Simulation
One can estimate pi using something as simple as a dartboard; shoot darts at a square board, and the number of darts that land within 1 unit from the origin (or in a circle of radius 1 unit) divided by the number of darts outside the circle is a simple estimate of the ratio between the area of the circle and that of the square: pi. Theoretically, with infinite darts, one could determine the exact value of pi. The interactive example below simulates the throwing of many darts and the resulting estimate of pi.