Skip to content

Estimate the value of π using a Monte-Carlo method

Notifications You must be signed in to change notification settings

san-coder1/MonteCarlo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MonteCarlo

By generating many random values, you can estimate the result of complicated mathematical equations via a technique known as the Monte Carlo method. You can estimate the value of π using a Monte-Carlo method.

Envision a unit circle (radius = 1). Specifically, we will work with the top right quadrant where all valid points are between { x = 0, y = 0 } and { x = 1, y = 1 }. By randomly generating many x, y pairs and calculating the length of the hypotenuse of a triangle with sides of length x, y using the Pythagorean theorem, hypotenuse=√(x^2+y^2 ), you can classify the pairs into those that overlap the unit circle (hypotenuse<= 1, blue shaded area) and those that fall outside the unit circle (hypotenuse>1, red shaded area). (See readme.docx for picture)

The ratio of pairs that overlap the unit circle divided by the total number of pairs generated is the area of the unit circle in the top right quadrant.

About

Estimate the value of π using a Monte-Carlo method

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages