The purpsose of this project is to create a Monte Carlo simulation of the geometric probability problem, Buffon's Needle. This simulation ultimately arrives at an estimation of the mathematical constant Pi.
- Monte Carlo Simulation
- Data Visualization
- Python (v.3.7)
- Pandas
- NumPy
- MatPlotLib
This project seeks to recreate the procedures of the classic geometric probability problem of Buffon's Needle. For context, the mathematician Georges-Louis Leclerc, the Count of Buffon, sought to approximate the value of Pi. At this time the constant of Pi was known, however its value beyond approximately 3 was not yet determined.
The Count thus devised a method of approximating the value of Pi using multi-variable calculus and probality, that could approximate the value of pi by conducting a randomized basic physical procedure many time (i.e. a Monte-Carlo simulation). His procedure was simple. He attained a board of arbitrary dimensions (L x W). On this board, he drew parallel lines across the length of the board, similar to yard-lines on a football field, each n inches apart in distance. He then threw a needle, also of length n inches, randomly on to the board. Using the aforement calculus and probability, he knew that the probability the needle would cross any of the drawn yard-lines was 2/Pi. Therefore, all he had to do was physically throw this needle many times on to this board to back out the value of pi. For more reading on the math behind this realization, see Buffon's Needle.
This script thus simulates the thousands of random throws of a needle on to the board to derive the value of pi. This script utilizes pseudo-randomness to achieve needles positioning, plot all the needles on to board, and estimate the value of pi. The estimated value is compared to the actual value of pi and an error is calculated for reference. Additionally, a csv file is exported with all the needles thrown.
To perform the simulation, simply run the script in the buffon_monte_carlo_sim directory and a plot of the board will automatically be generated. The parameters of sample size and significant figures may adjusted higher or lower as desired. Note that the higher the both parameters are set, the more accurate the estimation, however this will also increase the run-time. A csv file of all the needles postions will be automatically exported to the same directory.
Gunnar Dahm