Imagine a square of width two and area four such that a circle of radius one is within its boundaries. Compute pairs of random coordinates (random points) that lie within the square. The fraction of points within the circle is an estimate of the ratio of the area of the circle to that of the square. As the number of trials becomes large, four times this ratio should approach pi. Why?
This simulation is an example of a Monte Carlo method. Monte Carlo methods can be used to estimate the area (volume) of an irregular object in any dimension. Although this method is inefficient for low dimensions, it is very efficient for high-dimensional integrals and is often used in statistical mechanics models.
Gould, Tobochnik, and Christian An Introduction to Computer Simulation Methods 3ed page 421.
This simulation was created by Wolfgang Christian using the Easy Java Simulations (Ejs) modeling tool. You can modify this simulation if you have Ejs installed by right-clicking within a plot and selecting "Open Ejs Model" from the pop-up menu item. Information about Ejs is available at: <http://www.um.es/fem/Ejs/>.