calculation of pi using the monte carlo method

12
Calculation of Pi Using the Monte Carlo Method Presented by: Monzur Morshed Habibur Rahman Tiger HATS www.tigerhats.org

Upload: tigerhats

Post on 11-Sep-2014

251 views

Category:

Documents


3 download

DESCRIPTION

Calculation of Pi Using the Monte Carlo Method

TRANSCRIPT

Page 1: Calculation of Pi Using the Monte Carlo Method

Calculation of Pi Using the Monte Carlo

Method

Presented by:

Monzur MorshedHabibur Rahman

TigerHATSwww.tigerhats.org

Page 2: Calculation of Pi Using the Monte Carlo Method

The International Research group dedicated to Theories, Simulation and

Modeling, New Approaches, Applications, Experiences, Development, Evaluations, Education, Human, Cultural and Industrial Technology

 

TigerHATS - Information is power

Page 3: Calculation of Pi Using the Monte Carlo Method

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

Monte Carlo Methods

Page 4: Calculation of Pi Using the Monte Carlo Method

Calculation of Pi Using the Monte Carlo Method

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

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,

Page 5: Calculation of Pi Using the Monte Carlo Method

Calculation of Pi Using the Monte Carlo Method

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

Page 6: Calculation of Pi Using the Monte Carlo Method

Monte Carlo method applied to approximating the value of π

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

Page 7: Calculation of Pi Using the Monte Carlo Method

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

Page 8: 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.

Calculation of Pi Using the Monte Carlo Method

Page 9: Calculation of Pi Using the Monte Carlo Method

01 circleArea = 002 squareArea = 003 for(i=1 to 1000):04 x = random value from [0,1]05 y = random value from [0,1]06 if (x,y) within the circle:07 circleArea = circleArea + 108 squareArea = squareArea + 109 pi = 4.0*circleArea/squareArea10 print pi

Pseudo-code

Page 10: Calculation of Pi Using the Monte Carlo Method

01 withinCircle(x,y)02 if(x^2+y^2<=1):03 return True04 else:05 return False

To check whether (x,y) lies within the circle (including the circumference) use the following function:

Pseudo-code

Page 11: Calculation of Pi Using the Monte Carlo Method
Page 12: Calculation of Pi Using the Monte Carlo Method

Thank You.