We study models that use random numbers to generate statistically predictable outcomes. Examples include Monte Carlo methods and random walks on a lattice. Many of the random walk models are described in Chapter 7 of An Introduction to Computer Simulation Methods.
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.
Modify the model so that multiple Monte Carlo steps are computed during each evolution step.
The following EJS models use random numbers to generate statistically predictable outcomes.
An Introduction to Computer Simulation Methods 3-ed by Harvey Gould, Jan Tobochnik, and Wolfgang Christian Addison-Wesley (2007) pages 421-424, ISBN: 0-8053-7758-1.
The Monte Carlo Pi Model was created by Wolfgang Christian using the Easy Java Simulations (Ejs) modeling tool. It is based on a Java program from An Introduction to Computer Simulation Methods.
You can examine and modify a compiled EJS model if you run the model (double click on the model's jar file), right-click within a plot, and select "Open Ejs Model" from the pop-up menu. You must, of course, have EJS installed on your computer. Information about Ejs is available at: <http://www.um.es/fem/Ejs/> and in the OSP comPADRE collection <http://www.compadre.org/OSP/>.