# Monte Carlo method

The Monte Carlo method is a method of estimating the true value of a quantity by carrying out a lot
of random samples. For example, suppose we
want to know the probability of getting a double six when we roll two dice and that we don't know how to calculate this. We could roll a pair of dice
a thousand times, and count how many times, *n*, a double six came
up; the estimated probability would then be *n*/1000. A famous example
of using the Monte Carlo method is to calculate pi. Get a computer to generate
two random numbers *x* and *y*, each in the range –1 to 1, so
that the point (*x*, *y*) lies somewhere randomly inside a square
of side 2 units. Do this thousands of times, and count up what proportion
of the points also lie inside the circle (you can tell whether a point does
or not by working out whether *x *^{2} + *y*^{2} < 1). The proportion inside the circle is an approximation to *p*/4
(because the circle has area p but the square has area 4); millions of points
to obtain a good estimate.

This method was developed by researchers working on the Manhattan Project during World War II. To answer some of their scientific questions, they would repeatedly sample from their best estimates of the partial results, then apply the math they knew to the interactions and study the range of results. This process, which they named after the famous Monaco casino town of Monte Carlo, was created by John von Neumann and Stanislaw Ulam. The term and a description of the method seems not to have been published until some time after the war.