Monte Carlo Simulation-Project
Monte Carlo Simulation-Project
Simulation
Fawaz
Dr. A. obeidat
hrahsheh
Departmen
t of physics
just
History
What is Monte Carlo (MC) method ?
Inputs outputs
Measures of
Decision and
Simulation performance or
uncontrollable
model behaviour of the
variables
system
A simulation model cont..
• Model inputs capture the environment of the problem
• The simulation model
– Conceptual model: set of assumptions that define the
system
– Computer code: the implementation of the conceptual
model
• Outputs describe the aspects of system behaviour that we
are interested in
Random numbers
area of circle r
2
area of circle
4*
area of square
Cont..
area.of .circle
..of .dots.inside.circle
#.
area.of .square total .number .of .dots
I f ( x ) dx a, b R
a
s area.under.curve f ( x)dx
a
( x) 0 ( x ) dx 1
a
h( x ) f ( x ) ( x )
Theorem….
If x1,x2,x3,…..,xN are i,i,d uniformly distributed on
[a,b],then f 1 f ( x )
I f ( x)dx (b a) f ,
b N
N
i
i 1
a
Cont… 1
From the theorem choose ( x) b a andh( x) (b a) f ( x)
Then an estimate of I is
ˆ (b a ) N
I f (x )
N
i
i 1
var( Iˆ)
(b a )
var( f )
2
f
N
var( f ) f f
2 2
1 N 1 N
f ( x ) [ f ( x )]
2 2
x
N N
i i
i 1 i 1
a b
Sample Mean MC algorithm
♠ Generate sequence of N of PRN : Ri
♠Compute Xi=a+Ri (b-a)
♠ compute f(Xi) , i=1,2,3,….,N
♠ use Iˆ (b a ) f ( x )
N
N
i
i 1
( x) 0 and ( x ) dx 1
The estimate of I is
ˆ 1 N V N
I h( x ) f ( X )
N N
i i
i 1 i 1
Importance Sampled method
is quite obvious that most of the integral comes from the
egion of the peak. But if we generate points evenly in the
nterval [a, b], most points won’t be in the peak area ,and
their contribution to the total will be relatively small….
●The idea behind importance sampling is to
f(x) into another, flatter
transform
function
which is then MC integrated
of
course there has to be
a back-transformation
to give the original integral
mportant properties of continuous and discrete pdf
Steps of Importance Sampled method
b
rewrite I f ( x ) dx by I h( x ) g ( x ) dx
b
a a
f ( x)
where h( x )
g ( x)
b x
I h( x ) dG ( x ) where G ( x ) g ( x ) dx
a
0
f (G (u ))
G (b) 1
I du
g (G (u ))
G(a)
1
Cont….
now the value of the integration equal to the average valu
1 f (G (u ))
N
1
I i
N g (G (u ))
i 1
1
i
g g g
2
N g g
2
find I e dx
x2
0 e e
Then our normalized weighting function is
e e x
g ( x)
e 1
Cont....
x
e x
1 x
G ( x) g ( x)dx dx
0 e 1 0
(1 e )e
x
G ( x)
e 1
let u G (x)
e 1
x G (u ) log (1 u
1
)
e
e
Then
e 1
G (u ) log (1 u
1
)
e
i e i
Cont…
♣♣♣ note:: from the last result we redistribute the PRN
according to the pdf (g(x)) , then the new values
(i.e., G (u )) are uniform random numbers used
1
i
I i
N g (G (u ))
i 1
1
i
Trapezoidal rule N 2
N
2
d
Simpson’s rule N 4
N
4
d
I f ( x )dx
i i
Where i=1,2,3,……,30