Member-only story
Approximate the value of pi by performing a Monte Carlo approximation in Excel
Pi is a very useful number in the universe. It is the ratio of the circumference of a circle to its diameter. And is approximately equal to 3.14159. In a circle, if you divide the circumference by the diameter, you will get the number pi.
One way to estimate the number Pi is to carry out a Monte Carlo approximation. Monte Carlo methods are used in Bayesian Statistics to generate random variates from given distributions. Monte Carlo methods and Bayesian statistics are related because Bayesian statistics recommends Monte Carlo methods for generating random variates from given distributions.
In this blog post I intend to use Monte Carlo methods in Excel to approximate the value of pi.
The first thing that I did was to open up a blank page in the workbook that I was working on and create five columns of data, being:-
- Column A is X
- Column B is Y
- Column C is distance
- Column D is inside circle
- Column E is pi approximation
In column A, enter the formula RAND() from cell A2 to cell A250. This will generate random numbers from 0 to 1 in all of those cells:-