1 / 21

Hit-and-Miss (or Rejection) Monte Carlo Method:

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

rolf
Download Presentation

Hit-and-Miss (or Rejection) Monte Carlo Method:

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


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

  2. Lab 1. Calculation of the value of /4 Simple, Brute-Force, Hit-and-Miss Monte Carlo Method • Obtain an approximate value of A (= /4  M/M) by • throwing M stones in the square of the total area 1; • counting M stones in a quarter of the circle of the radius 1. • 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 Oi values at each microstate (xi, yi) (i = 1 to M). • What values can Oi take? • (2) How does the value of Oi depend on (xi, yi)?

  3. Lab 1. Calculation of the value of /4 Simple, Brute-Force, Hit-and-Miss Monte Carlo Method • Obtain an approximate value of A (= /4  M/M) by • throwing M stones in the square of the total area 1; • counting M stones in a quarter of the circle of the radius 1. • 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 Oi values at each microstate (xi, yi) (i = 1 to M). • What values can Oi take? • Answer: 0 or 1 • (2) How does the value of Oi depend on (xi, yi)? • 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 Oi values.

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

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

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

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

  9. Lab 1. Calculation of the value of /4 (or ) 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. Otot = 0; O2tot =0; input seed Flow chart for Question 7: Calculate . i = 1 O = 0.0 x=ran3(&seed); y=ran3(&seed) yes O = 1.0 no Otot = Otot + O; O2tot = O2tot + O2 i = i + 1 no yes Obar = Otot/M; O2bar = O2tot/M; = sqrt(O2bar  Obar2) pi = 4 x Obar; _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. Otot = 0; O2tot =0 Flow chart for Question 9: Calculate  over n estimates. i = 1 O = 0.0 x=ran3(&seed); y=ran3(&seed) yes O = 1.0 one_estimate no Otot = Otot + O; O2tot = O2tot + O2 i = i + 1 no yes Obar = Otot/M; O2bar = O2tot/M; = sqrt(O2bar  Obar2) pi = 4 x Obar; _pi = 4 x 

  16. Obartot= 0; Obarsqtot=0; tot = 0; input seed Flow chart for Question 9: Calculate  over n estimates. j = 1 one_estimate Obartot = Obartot + Obar Obarsqtot = Obarsqtot + Obar2 tot = tot+  j = j + 1 no yes Obarbar = Obartot/n Obarsqbar = Obarsqtot/n bar= sqrt(Obarsqbar  Obarbar2) bar= tot/n pi = 4xObarbar; 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. Lab 1. Calculation of the value of /4 (or )

More Related