











Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Main topics for this course are Stochastic process, random variables, linear congruent generators, pdfs and cdfs, rejection method, metropolis methods, sampling techniques, random walks and genetic algorithm. This lecture includes: Direct, Sampling, Target, Population, Random, Collection, Replacement, Stratified, Monte, Carlo, Sequence, Cumulative, Distribution, Function
Typology: Slides
1 / 19
This page cannot be seen from the preview
Don't miss anything!












We
Collect
data
that
will
provide
information
on
the
phenomena
of
interest.
Using data we draw conclusions.
Then researcher generalizes from that experiment to the class of all suchexperiments.
However, we are not absolutely certain about our conclusions.
Using statistical techniques, we can measure and manage the degree ofuncertainty in our results. Target Population is defined as the entire collection of objects or individualsabout which we need some information. Sample Population is only a part of the entire collection of objects orindividuals. Random Sample Population is a part of the entire collection of objects orindividuals that are randomly selected from Target Population.
docsity.com
Carlo
calculation
is
a
numerical
stochastic
process.
It
is
usually required that random variables be drawn from distributionfunctions that derive the process.
For example, the integral is given.
Its Evaluation requires that values of x must be drawn using
f(x)
and
the
value
of
average
of
g(x)
over
such
set
of
x
values
be
calculated. This is the process of “sampling x from f(x)” and it is an essential techniquefor any Monte Carlo simulation.^ We may also say that the sampling process is an algorithm thatcan produce a sequence of values of x (random variables) suchthat for any W that belongs to a universal set:
. 1
) (
}
{^
≤
= Ω ∈
∫^
dx x f
x P
k
f(x). This is “sampling the function f(x)”.
The cumulative distribution function (cdf) is defined as
x ∫ a
Where the range of x is in [a, b].
This function plays a central role in the Monte Carlo work.
The normalization
The F(x) represents the probability that a random variable from f(x) liesbetween a and x.condition also requires that
∫^
b a
Example 2:
Direct Sampling
Let us perform the sampling of function f(x).
Suppose that the given
pdf for y is an
exponential probability distribution.
∞ < <
−
=^
y
y
y f^
0 )
exp(
) (
λ
λ
y F Then the cumulative distribution is The
F(y)
represents the probability that a random variable from
f(y)
lies between 0 and y.
=^ ∫
exp( 1 )
exp(
) (
0
y
y
y F
y
ξ
λ
ξ
λ
ξ
λ
MATLAB Program on
Exponential
Distribution Sampling
%^ MC Sampling for f(y) = lambdaexp(-lambday) % Exponential Distribution sampling program in MATLAB**^ N = 10000 ;
% No of histories to be generated
max_bins = 500;
% Max. no of bins
xlambda = 2.0; rand('state', 0)
% initialize to zero
for j=1:max_bins
% initialize
ibin(j) = 0; xmid(j) = 0; ntheory(j)=0; end for i= 1:N
% Start Monte Carlo loop
yy = rand;
% choose random F
ff(i) = -log(yy)/xlambda; % calculate function end max_ff = 5;
% find max value of func estimated
size_bin = max_ff/max_bins;
% find size of bins
for kk=1: N
% put all in bins
l_limit=0; u_limit=0; for ii=1: max_bins l_limit = (ii-1)size_bin; u_limit = iisize_bin; if((ff(kk)>l_limit)&(ff(kk)<=u_limit)) jj=ii; end end ibin(jj) = ibin(jj) + 1; % one more for the bin end for k = 1:max_bins
xmid(k) = (k - 0.5)size_bin;*
% compute mid-point
% compute the expected pdf
fx = xlambdaexp(-xlambdaxmid(k)); ntheory(k) = Nfxsize_bin;**
% no by theory
end^ plot(xmid, ibin,'r+',xmid, ntheory,'b.')
0
1
2
3
4
5
5 0^0 2 5 0 2 0 0 1 5 0 1 0 0
Example 2: N = 10000, No. of Bins = 500, Lambda = 2.
Direct Sampling
ExponentialDistributionSampling
docsity.com
(^
)^
.
0
, 1
;
1
) (^
∞ ≤ ≤
>
=^
x
n
bx a
x w^
n
.
) 1
(
1
) ( 0
1
∞ ∫
−
−
=^
n ba
n
dx x w
First we find its normalization constant: So, normalized pdf is given as
∫^
−
=
x
n a bx
dx x f
x F
0
1 ) /
(^1) (
1 1 ) ( ) (
. 1
0
; 1
) (
) (^
) 1 /( 1
1
< <
−
=
⇒
=^
− −
−
ξ
ξ
ξ
ξ^
n
a b
x
F x Then the Cumulative distribution is given as
.
0
, 1
;
) 1
( ) (
1
∞ ≤ ≤
>
− +
=
−
x
n
bx a
ba
n
x f^
n n
Example 3:
Direct Sampling
Consider another example of a pdf with the following form:
0
1
2
3
4
5
0 1000900800700600500400300200100 f(x)
Monte Carlo MethodTheory x
Parameters Used: a =10,
b = 1,
n = 2
N = 10000, No. of bins
=
200
Range for x
== (0, 5) (^
)
.
1
−
x n
bx a
ba n
x f^
n n
Example 3:
Direct Sampling
docsity.com
Example 4: Sampling a Gaussian Distribution The Gaussian or a Normal distribution function is not easily sampled in directmanner. The pdf is given as following: And cumulative distribution function is given as Thus to sample the area (probability), we must take a slice of the area:
.
0
);
exp( 2 ) (^
2
∞ ≤ ≤
−
=^
x
x
x f
∫
∫^
−
=
=
x
x^ dx e
dx x f
x F
0
2 2 ) ( ) (
π
This is error function is not simply invertible. However, one can use the trickof changing from rectangular to polar coordinates:
θ
π π
d drr
e
dy dx e e
dy dx y f x f
r
y x^2
2 2 (^44)
) ( ) (
−
− −
=
0
1
2
3
4
5
0 400 300 200 100
Example 4: Sampling a Gaussian Distribution Using a MATLAB program, we have following:^ Parameters Used:^ N = 10000,^ No. of bins = 200^ Range for x = (0, 5)
docsity.com
Consider a pdf
with the following form:
. 1
0
2 ) (^
≤ ≤
=^
x
x
x f ∫^
1 0
dx x f It is correctly normalized since, Cumulative distribution is given as
∫^
x
x
dx x f
x F
0
2
x
x
So, choosing a number of values of
ξ
from uniform distribution
and taking square root will give such values of x that will have f(x) as
pdf.
Example 5: Sampling a pdf
0 2500 2000 1500 1000 500
No of histories = 50000,No. of Bins
= 40
pdf =
f(x)
= 2x, [0, 1]
f(x)
x-value
Monte Carlo resultsTheoretical pdf
We developed a MATLABprogram for sampling from apdf
with the following form:
. 1
0
2 ) (^
≤ ≤
=
x
x
x Example 5: Sampling a pdf f^ For about 50 thousandhistories the resultsfrom Monte Carlosimulations startedmatching very closelyto the actual pdf.
docsity.com