0% found this document useful (0 votes)
697 views

Calculation of Pi Using The Monte Carlo Method

The document describes calculating Pi using the Monte Carlo method. It involves randomly selecting x and y coordinate values between 0 and 1 and counting how many fall within a circle (radius of 1) compared to a total square area of 1. The ratio of points within the circle to total points multiplied by 4 approximates Pi. Pseudocode is provided to generate random points, check if they are within the circle, and calculate Pi based on the ratio.

Uploaded by

TigerHATS
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
697 views

Calculation of Pi Using The Monte Carlo Method

The document describes calculating Pi using the Monte Carlo method. It involves randomly selecting x and y coordinate values between 0 and 1 and counting how many fall within a circle (radius of 1) compared to a total square area of 1. The ratio of points within the circle to total points multiplied by 4 approximates Pi. Pseudocode is provided to generate random points, check if they are within the circle, and calculate Pi based on the ratio.

Uploaded by

TigerHATS
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 12

Calculation of Pi Using the Monte Carlo Method

Presented by: Monzur Morshed Habibur Rahman

TigerHATS
www.tigerhats.org

TigerHATS - Information is power


The International Research group dedicated to Theories, Simulation and Modeling, New Approaches, Applications, Experiences, Development, Evaluations, Education, Human, Cultural and Industrial Technology

Monte Carlo Methods


Stochastic techniques - based on the use of random numbers and probability statistics to investigate problems Large system ->random configurations, data-> describe the whole system "Hit and miss" integration is the simplest type

Calculation of Pi Using the Monte Carlo Method

If you are a very poor dart player, it is easy to imagine throwing darts randomly at Figure 2, and it should be apparent that of the total number of darts that hit within the square, the number of darts that hit the shaded part (circle quadrant) is proportional to the area of that part. In other words, Source: http://www.chem.unl.edu/zeng/joy/mclab/mcintro.html

Calculation of Pi Using the Monte Carlo Method

Source: http://www.chem.unl.edu/zeng/joy/mclab/mcintro.html

Monte Carlo method applied to approximating the value of

Source: http://en.wikipedia.org/wiki/File:Pi_30K.gif

Calculation of Pi Using the Monte Carlo Method Randomly select values for x and y 0 <= x,y <=1 Pi = 4 . (inside points / total points)

Source: http://www.modula2.org/projects/pi_by_montecarlo/est_pi.gif

Calculation of Pi Using the Monte Carlo Method


The algorithm in pseudo-code is given in next slide where for simplicity we have chosen the radius to be r=1 and examine only the first quadrant. Choosing only the first quadrant does not change the ratio. The code below does the following: - Choose 1000 or any say 100000 dots randomly. - If the dot lands within the circle count the dot by increasing the variable circleArea by 1. - At the end compare the number of dots within the circle with the total number of dots.

Pseudo-code
01 02 03 04 05 06 07 08 09 10 circleArea = 0 squareArea = 0 for(i=1 to 1000): x = random value from [0,1] y = random value from [0,1] if (x,y) within the circle: circleArea = circleArea + 1 squareArea = squareArea + 1 pi = 4.0*circleArea/squareArea print pi

Pseudo-code
To check whether (x,y) lies within the circle (including the circumference) use the following function: 01 02 03 04 05 withinCircle(x,y) if(x^2+y^2<=1): return True else: return False

Thank You.

You might also like