 Monte Carlo Approximation of Pi - Maple Help

Home : Support : Online Help : Math Apps : Probability and Statistics : Statistics : Monte Carlo Approximation of Pi

Monte Carlo Approximation of ${\mathrm{π}}$

Main Concept

Monte Carlo methods are a class of computational algorithms that repeat random samplings to obtain numeric results. In this example, Monte Carlo simulation is used to randomly sample points from a Uniform distribution in order to approximate a value for $\mathrm{π}$.

One way to estimate $\mathrm{π}$ is to compare the ratio of the area of a circle to the area of a square. Details

We begin by considering a circle inscribed in a unit square.

 > The area of the circle is:

The area of the unit square is: ${2}^{2}=4$

The ratio of the area of the circle to the area of the square is then:

This can be rewritten as .

The task of computing the ratio of the circle to the area of the square can be done as follows:

 1 We uniformly scatter points over the square. This is equivalent to randomly sampling points from a Uniform distribution between the minimum value $-1$ and the maximum value $1$.
 2 We count the total number of objects as well as the number inside of the square. We can note that if ${x}^{2}+{y}^{2}\le 1$, a given point falls inside the circle; otherwise, it falls outside.
 3 The ratio of the two counts is an estimate for the ratio of the two areas. Multiplying this by 4 gives an estimate for $\mathrm{π}$.

Adjust the number of points being plotted and see how it affects the approximation of $\mathrm{\pi }$. Note that Monte Carlo simulation uses random sampling, so the estimate will not be exactly the same every time you run a simulation.

number of dots$\mathbf{=}$ More MathApps