Case Study: PI calculation with MC

This sample model is provided with all new Expert Models accounts.

Summary

This model uses Monte Carlo to estimate the value of Pi (mathematical constant).

The mathematical constant PI is defined as the ratio of the circumference of a circle to its
diameter. This is a constant regardless of the circle size.

In the model, we generate ‘N’ pairs of random numbers based on the number of simulations provided
by the user. The pair represents the ‘x’ and ‘y’ values in the Cartesian co-ordinate system
x^2 + y^2 = 1

For simplicity, we consider quarter of an unit circle embedded in a square of unit size. Thus the
area would be quarter of an unit circle. Using Monte Carlo, we simulate points within the unit
square and try to find the number of points that fall within the quarter circle.

The ratio of points to the total points multiplied by 4 would give the value of PI. The example
gives a good approximation upto 2 d.p. Increasing the number of simulations would give more
accurate results.

Original source / documentation of model

Wikipedia – Monte Carlo Method

Output Type

A single value

Libraries Used

Default python libraries

Tagged: