Professional Documents
Culture Documents
Lecture 2-2 - Basic Statisitcs-2
Lecture 2-2 - Basic Statisitcs-2
I = ( x)dx
b
a
1. Hit-Or-Miss Method
a
h ( x) for any x h
X X
X
X
X
▪ Probability that a random point reside X
O
inside the area O
O
O O
I N'
r= O O
(b − a)h N
a b
Start
N’ = 0 h
X X
X
X
X
a b
if [x,y] reside inside then N’ = N’+1
I = (b-a) h (N’/N)
End
1. Hit-Or-Miss Method
▪ Estimation of error
0.6745s
s = V (X )
N
E ( X ) = xp( x) = 1 r + 0 (1 − r ) = r =
E ( X 2 ) = x 2 p( x) = 1 r + 0 (1 − r ) = r
V ( X ) = r − r 2 = (1 − r )r = s 2
s = (1 − r )r
I = r ( a − b ) h = ( a − b) h
b
( x)dx 1 b
= a
=
b−a ( x)dx
b a
dx
a
I = ( x)dx = (b − a)
b
N
1
=
N
(x )
n =1
n
▪ Variance 1 N
= ( xn ) 2
2
V ( ) = 2 − N n=1
2
V ( x)
I SM
error = 0.6745s = (b − a) 0.6745
N
2. Sample Mean Method
L ( x) 2 dx − I 2
b
SM
I error = 0.6745 a
N
2. Sample Mean Method
Start
s1 = 0, s2 = 0
Loop xn = (b-a) un + a
N times
yn = (xn)
s1 = s1 + yn , s2 = s2 + yn2
V'
Estimate mean ’=s1/N
Estimate variance V’ = s2/N – ’2
SM
I error = (b − a) 0.6745
N
End
Example)
L ( x) 2 dx − I 2
b
SM
I error = 0.6745 a
N
Example)
b−a 0
1 2
V () = − 2
2
V' ( 2 / 4)(1 / 2 − 4 / 2 ) 2 / 8 −1
I SM
error = 0.6745(b − a) = 0.6745 = 0.6745
N N N
Example) Comparison of HM and SM
▪ Comparison of error
2
SM −1
I error 8
= 0.64 SM method has 36 % less error than HM
HM
I error
−1
2
I SM
= 0.6745 a
▪ More points are sampled near the peak →”importance sampling strategy”
3.1 Variance Reduction using
Generalized Rejection Technique
w( x) ( x) w(x)
(x)
W ( x) = w( x)dx
x
X
X
−
X
X
A = w( x)dx
b O
O
a O
O O
Au = w(x) x = W −1 ( Au) O O
a b
▪ Points are generated on the area under w(x) function
▪ Random variable that follows distribution w(x)
3.1 Variance Reduction using
Generalized Rejection Technique
1 if yn ( xn )
X
O
qn = O
0 if yn ( xn )
O
O O
O O
a b
q 1 0
r=I/A
P(q) r 1-r
3.1 Variance Reduction using
Generalized Rejection Technique
▪ Error Analysis
E (Q) = r , V (Q) = r (1 − r )
I = Ar = AE(Q)
I(A− I)
0.67
RJ Hit or Miss method
I error
N A = (b − a)h
Error reduction
A→I then Error → 0
3.1 Variance Reduction using
Generalized Rejection Technique
▪ Error Analysis
E (Q) = r , V (Q) = r (1 − r )
I = Ar = AE(Q)
I(A− I)
0.67
RJ Hit or Miss method
I error
N A = (b − a)h
Error reduction
A→I then Error → 0
3.1 Variance Reduction using
Generalized Rejection Technique
Start
X
O
I '(A − I ')
I = (b-a) h (N’/N) I RJ
error 0.67
N
End
3.2 Variance Reduction using
Importance Sampling Method
▪ Basic idea
▪ Put more points near maximum
▪ Put less points near minimum
F ( x) = f ( x)dx
x
−
y = F ( x)
x = F −1 ( y )
3.2 Variance Reduction using
Importance Sampling Method
dy / dx = f ( x) → dx = dy / f ( x)
( x) ( x)
I = dy =
b b
f ( x)dx
a f ( x) a
f ( x)
( x)
( x) =
f ( x)
f = ( x) f ( x)dx
b
I = ( x) f ( x)dx = f
b
a
3.2 Variance Reduction using
Importance Sampling Method
▪ Estimation of Error
1 N
I = f ( xn )
N n=1
V f ( )
I error = 0.67
N
V f ( ) = 2 f −( f )2
2 f −I 2
IS
I error = 0.67
N
3.2 Variance Reduction using
Importance Sampling Method
Start
s1 = 0 , s2 = 0
n = (xn) / f ( xn)
Add n to s1
Add n2 to s2
V'
I ‘ =s1/N , V’=s2/N-I’2
IS
I error = 0.67
N
End
4. Comparison ....
▪ Methodological Approach
▪ Rectangular Rule, Triangular Rule, Simpson’s Rule
f ( x)
I = f ( x ) dx
a
Quadrature Formula
n
b−a n
x I x f ( xi ) = f ( xi )
i =1 n i =1
Uniformly separated points
Comparison ....
b−a n
I
n i =1
f ( xi )
▪ Comparison of errors
▪ Methodological Integration E x 2 / n 2
▪ Monte Carlo Integration E 1 / n1/ 2
▪ MC error vanishes much slowly for increasing n
▪ For one-dimensional integration, MC offers no
advantage
▪ The conclusion changes when dimension of integral
increases
▪ Methodological Integration E x 2 / n 2 / d
▪ Monte Carlo Integration
E 1 / n1/ 2
MC “wins” about d = 3~4
Shape of High Dimensional Integral
+
2 2
( x y )dxdy
r 2 =
dxdy
Shape of High Dimensional Integral
A =
A(r )(−U (r ) / kT )dr
1 inside R
s=
0 outside R
+0.5 +0.5
r2 =
−0.5 dx
−0.5
dy ( x 2 + y 2 ) s( x, y )
+0.5 +0.5
−0.5 dx −0.5 dys( x, y)
Grid must be fine enough !
Integration over simple shape ?
▪ Importance Sampling :
▪ Put more quadrature points in the region where
integral receives its greatest contribution
▪ Choose quadrature points according to some
distribution function.