#
All entries for Thursday 18 October 2018

## October 18, 2018

### A low–tech Monte Carlo technique to approximate π

Monte Carlo algorithms are used in solving involved integrals with no close-form solution. For no mathematicians this first sentence may have already appeared difficult and cumbersome. However, we should think of Monte Carlo techniques as a powerful ally in real difficult problems. Lets explore an easy example of Monte Carlo technique to get familiar with it. Suppose that you'd like to estimate the value of π. Draw the following perfect square on the ground and inscribe a circle in it:

Now take a bag of rice and scatter 20 grains uniformly at randominside the square:

Now assuming that the scattering was random the ratio between the circle's grains (C) and the square's grains (S) should approximate the ratio between the are of the circle and the are of the square given by:

C/S = π(d/2)^2/d^2

Solving for π we get:

π ~ 4C/S

Which in the approximation of our example is: 4*15/20 = 60/20 = 3.

We have approximated the value of π to be 3, not too bad for a Monte Carlo simulation with only 20 random points.

(The figure was adapted from https://towardsdatascience.com/a-zero-math-introduction-to-markov-chain-monte-carlo-methods-dcba889e0c50, and the text from GIBBS SAMPLING FOR THE UNINITIATED, go visit these resources if you'd like to learn more about MCMC)