Maciej A. Czyzewski Blog Talks About

# Monte Carlo method, calculating π

Posted on

Monte Carlo methods/experiments are a class of computational algorithms that rely on repeated random sampling to compute their results.

These methods are most suited to calculation by a computer and tend to be used when it is unfeasible or impossible to compute an exact result with a deterministic algorithm.

## Calculations

Now, we try to apply it to calculate an approximate value for π. Let’s start with the mathematical foundations of the problem.

The idea is to approximate an area by counting dots, which are randomly scattered over the area. We want to compare the number of dots located in a circle, to the whole field.

Using the relationship between these fields and knowing the formula for the area of the square and the circle, we get:

Therefore:

## Results

Approximate value for Pi:         3.1424
Difference to exact value of Pi:  0.000807346410207
Error in percent:                 0.0256986343944 %


Risk analysis is part of every decision we make. We are constantly faced with uncertainty, ambiguity, and variability.