dcsimg
 

A Simple Guide to Using Monte Carlo Simulation to Estimate Pi

Monte Carlo simulation has all kinds of useful manufacturing applications. And - in celebration of Pi Day - I thought it would be apropos to show how you can even use Monte Carlo simulation to estimate pi, which of course is the mathematical constant that represents the ratio of a circle’s circumference to its diameter. For our example, let’s start with a circle of radius 1 inscribed within a square with sides of length 2.

We can then use Monte Carlo simulation to randomly sample points from within the square. More specifically, we can randomly sample points using a uniform distribution where the minimum is -1 and the maximum is +1:

Since:

Then the ratio of the two areas - we'll call it r - can be represented as:

We can use the Monte Carlo Simulation tool in Companion by Minitab to run a simulation with 1,000,000 iterations.

pi monte carlo simulation

As shown in the output below, the results of the simulation are that 78.56% of the values will fall outside of the circle. (Since Monte Carlo simulation uses random sampling, this number will not be exactly the same every time you run a simulation.)

output of monte carlo simulation of pi

In other words, our r is 0.7856. Therefore, if we use the r value generated using Monte Carlo simulation, we have:

pi equation

Solving for pi, we multiply 0.7856 * 4 which gives us an approximation for pi of 3.1424. And that is how we can use Monte Carlo simulation to estimate pi.

Comments

blog comments powered by Disqus