truongluan303 / pi-estimate-visualization-using-monte-carlo-method

a simple program that estimates the value of Pi using the Monte Carlo Method that is written totally in Python

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Estimate Pi using Monte Carlos method

This is a simple program that estimate the value of Pi using the Monte Carlo Method that is written totally in Python

estimating-pi-monte-carlo-method

From the image above, we can easily calculate the Area of the circle and the square

equation

Therefore, we can simulate this situation by creating a big number of points that are randomly distributed on the image. ALL of the points generated (BOTH blue & red) will represent A_square. The total number of points that are inside the circle (ONLY red) will represent A_circle From there, we can do the calculation and estimate the number pi

I am using pygame for the graphical interface The longer we run the program, the more accurate the output will be

This is how the output looks like:

Estimate.Pi.2021-06-27.16-35-55.mp4

About

a simple program that estimates the value of Pi using the Monte Carlo Method that is written totally in Python


Languages

Language:Python 100.0%