hit-and-miss (or rejection) monte carlo method: a “brute-force” method based on completely...
TRANSCRIPT
MM
M
M
MA
M largefor lim
4
bar
M
ii
tot
M
ii
OOOMM
MA
OOMM
1
1
1
(hit)
)1 (if otherwise (miss) 0
1 if (hit) 1
2
2
iii
iii
xyO
xyO
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?
:as observablean Define
times.Mfor ),( randomat Choose
O
yx ii
1. Generation of M 2D microstates
2. Measurement (Averaging an observable over M microstates)
x
y
A
O 1
1
(xi,yi)
1,0 ,1)( 2 xxxfy
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 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 Oi values at each microstate (xi, yi) (i = 1 to M).
(1)What values can Oi take?
(2) How does the value of Oi depend on (xi, yi)?
bar
M
ii OOO
MM
M
M
MA
1
1
(throw)
(hit)
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 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 Oi values at each microstate (xi, yi) (i = 1 to M).
(1)What values can Oi take?
Answer: 0 or 1
(2) How does the value of Oi depend on (xi, yi)?
Answer:
bar
M
ii OOO
MM
M
M
MA
1
1
(throw)
(hit)
21 if (hit) 1 iii xyO
)1 (if otherwise (miss) 0 2iii xyO
Lab 1. Calculation of the value of Question 2 (Algorithm & Flow chart).
Draw a flow chart to estimate 4A by averaging over M instantaneous Oi values.
bartot
M
ii OO
M
OO
MA
1
1
21 if ,1 iii xyO
otherwise ,0iO
Lab 1. Calculation of the value of
?1 2xy
Otot = Otot + O
O = 0.0
O = 1.0
yes
no
x=ran3(&seed)y=ran3(&seed)
i = 1
i = i + 1
?Mi no
Otot = 0.0
Obar = Otot/M x 4
yes
Question 2 (Algorithm & Flow chart).
Draw a flow chart to estimate 4A by averaging over M instantaneous Oi values.
bartot
M
ii OO
M
OO
MA
1
1
21 if ,1 iii xyO
otherwise ,0iO
Question 3. Write a program to estimate 4A by averaging over M instantaneous O values. Try M = 10,000.
Lab 1. Calculation of the value of
trueOO
Question 3. Write a program to estimate 4A by averaging over M instantaneous O values. Try M = 10,000.
Lab 1. Calculation of the value of
trueOO
Lab 1. Calculation of the value of 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?
Lab 1. Calculation of the value of
(accuracy) or i.e., , deviation standard
)( variance
1limlim and
1
,,,,,, observablean of valuesousinstantane M ofset aFor
2222
11
21
OOOO
OOOO
OOM
OOOM
O
OOOOO
truetrue
true
M
iiMM
M
ii
Mi
Variance, Standard Deviation, Error, and Accuracy
Lab 1. Calculation of the value of
(accuracy) or i.e., , deviation standard
)( variance
1limlim and
1
,,,,,, observablean of valuesousinstantane M ofset aFor
2222
11
21
OOOO
OOOO
OOM
OOOM
O
OOOOO
truetrue
true
M
iiMM
M
ii
Mi
Variance, Standard Deviation, Error, and Accuracy
Lab 1. Calculation of the value of
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?
Lab 1. Calculation of the value of 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.