Presentation is loading. Please wait.

Presentation is loading. Please wait.

Hit-and-Miss (or Rejection) Monte Carlo Method: a “brute-force” method based on completely random sampling Then, how do we throw the stones and count them.

Similar presentations


Presentation on theme: "Hit-and-Miss (or Rejection) Monte Carlo Method: a “brute-force” method based on completely random sampling Then, how do we throw the stones and count them."— Presentation transcript:

1 Hit-and-Miss (or Rejection) Monte Carlo Method: a “brute-force” method based on completely random sampling Then, how do we throw the stones and count them on computer? 1. Generation of M 2D microstates 2. Measurement (Averaging an observable over M microstates) x y A O 1 1 (x i,y i )

2 Obtain an approximate value of A (=  /4  M/M) by (1) throwing M stones in the square of the total area 1; (2) counting M stones in a quarter of the circle of the radius 1. Lab 1. Calculation of the value of  /4 Simple, Brute-Force, Hit-and-Miss Monte Carlo Method Question 1 (Formulation of the problem = Restatement of the last page). On computer, this problem can be formulated as obtaining the average (or expectation value) of an observable O over M instantaneous O i values at each microstate (x i, y i ) (i = 1 to M). (1)What values can O i take? (2) How does the value of O i depend on (x i, y i )?

3 Obtain an approximate value of A (=  /4  M/M) by (1) throwing M stones in the square of the total area 1; (2) counting M stones in a quarter of the circle of the radius 1. Lab 1. Calculation of the value of  /4 Simple, Brute-Force, Hit-and-Miss Monte Carlo Method Question 1 (Formulation of the problem = Restatement of the last page). On computer, this problem can be formulated as obtaining the average (or expectation value) of an observable O over M instantaneous O i values at each microstate (x i, y i ) (i = 1 to M). (1)What values can O i take? Answer: 0 or 1 (2) How does the value of O i depend on (x i, y i )? Answer:

4 Lab 1. Calculation of the value of  /4 (or  ) Question 2 (Algorithm & Flow chart). Draw a flow chart to estimate A (or  = 4A) by averaging over M instantaneous O i values.

5 Lab 1. Calculation of the value of  /4 O tot = O tot + O O = 0.0 O = 1.0 yes no x=ran3(&seed) y=ran3(&seed) i = 1 i = i + 1 no O tot = 0.0 O bar = O tot /M;  = 4xO bar yes Question 2 (Algorithm & Flow chart). Draw a flow chart to estimate A (or  = 4A) by averaging over M instantaneous O i values. Answer.

6 Question 3. Write a program to estimate A by averaging over M instantaneous O values. Try M = 10,000. Lab 1. Calculation of the value of  /4 (or  )

7 Flow chart for Question 4: Calculate . O tot = O tot + O O = 0.0 no x=ran3(&seed); y=ran3(&seed) i = 1 i = i + 1 no O tot = 0; input seed O bar = O tot /M;  = 4O bar ;  true = acos(-1);  = fabs(  true  ) yes O = 1.0 yes

8 Question 3. Write a program to estimate A by averaging over M instantaneous O values. Try M = 10,000. Lab 1. Calculation of the value of  /4 (or  )

9 Question 6. But, what if we don’t know the true value of what we estimate? Since we can’t estimate the error  w.r.t. the true value, how could we estimate the accuracy (error) of the simulation?

10 Lab 1. Calculation of the value of  /4 (or  ) Variance, Standard Deviation, Error, and Accuracy

11 Lab 1. Calculation of the value of  /4 (or  ) Variance, Standard Deviation, Error, and Accuracy

12 Flow chart for Question 7: Calculate . O tot = O tot + O; O 2 tot = O 2 tot + O 2 O = 0.0 O = 1.0 yes no x=ran3(&seed); y=ran3(&seed) i = 1 i = i + 1 no O tot = 0; O 2 tot =0; input seed O bar = O tot /M; O 2 bar = O 2 tot /M;  = sqrt(O 2 bar  O bar 2 ) yes pi = 4 x O bar ;  _pi = 4 x 

13 Lab 1. Calculation of the value of  /4 (or  ) Answer: We expected that  would be similar to  (    ), but it’s not the case (  >  ).  (~constant with M) is much larger than  (which decreases as M increases)! Thus,  itself is not a good indicator of the accuracy of a simulation. Question 8. Then, what else would be an indicator of the accuracy (error) of the estimation, when we don’t know the true value of what we estimate?

14 Lab 1. Calculation of the value of  /4 (or  )

15 O tot = O tot + O; O 2 tot = O 2 tot + O 2 O = 0.0 O = 1.0 yes no x=ran3(&seed); y=ran3(&seed) i = 1 i = i + 1 no O tot = 0; O 2 tot =0 O bar = O tot /M; O 2 bar = O 2 tot /M;  = sqrt(O 2 bar  O bar 2 ) yes pi = 4 x O bar ;  _pi = 4 x  one_estimate Flow chart for Question 9: Calculate  over n estimates.

16 Flow chart for Question 9: Calculate  over n estimates. O bartot = O bartot + O bar O barsqtot = O barsqtot + O bar 2  tot =  tot +  one_estimate j = 1 j = j + 1 no O bartot = 0; O barsqtot =0;  tot = 0; input seed O barbar = O bartot /n O barsqbar = O barsqtot /n  bar = sqrt(O barsqbar  O barbar 2 )  bar =  tot /n yes pi = 4xO barbar ;  barpi = 4x  bar ;  barpi = 4x  bar

17 Lab 1. Calculation of the value of 

18 Lab 1. Calculation of the value of  /4 (or  ) Question 10. But, what if we move onto a very complex problem? Each estimation (simulation) with M trials becomes so time-consuming that we couldn’t afford to running the simulation many times. What should we do in this case? Answer: Let’s try to find a way to estimate the accuracy  from one M-trial simulation.

19 Lab 1. Calculation of the value of  /4 (or  )

20

21


Download ppt "Hit-and-Miss (or Rejection) Monte Carlo Method: a “brute-force” method based on completely random sampling Then, how do we throw the stones and count them."

Similar presentations


Ads by Google