














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: Importance, Sampling, Direct, Method, Integrals, Variables, Probability, Distribution, Function, Arithmetic, Mean, Error, Variance, Lagrange
Typology: Slides
1 / 22
This page cannot be seen from the preview
Don't miss anything!















docsity.com
If the integral has the following form:
Where,
∫
∫ Ω
N
3
2
1
That is we sample the probability distribution function f(X) as doneearlier. Then we form the arithmetic mean as value of integral:
∑
i
i
N
g
docsity.com
There are three major classes of techniques that are used to reduce the variance in Monte Carlo calculations. 1.
Importance Sampling can be used to increases the likelihood ofsampling variable where the function is large or rapidly varying.
The expected value of the random variable can be used ratherthan the variable itself.
Correlations between succeeding samples may be exploited tothe advantage.
In control variates, an easily evaluated approximation to theintegrand is used to reduce the variance.
How to Reduce Variance
IMPORTANCE SAMPLING may be the answer to this all !!!
docsity.com
Suppose we have an n-dimensional integral:
∫
=
dX
X
f
X
g
G
)
(
)
(
And we wish to evaluate it. The function f(X) is not necessarily thebest pdf to be used in Monte Carlo calculation even though it is inthe integrand. A different pdf, h(X) can be introduced as following:
Where,
∫
⎤ ⎥ ⎦
⎡ ⎢ ⎣
=
dX
X
h
X
h
X
f
X
g
G
)
(
)
(
)
(
)
(
∫
=
≥
, 1 ) ( , 0 ) (
dX
X
h
X
h
and
∞
<
)
(
)
(
)
(
X
h
X
f
X
g
docsity.com
A Monte Carlo method to evaluate the integral would be to sample a series of X values from h(X) and then construct the following sum:
∑
=
=
N
i
i
i
i
N
X
h
X f X g N G
1
)
(
) ( ) ( 1 ~
This clearly corresponds to the minimum variance calculation. As a first example, let us consider one integral to be estimated.
docsity.com
let us consider the integral:
(
)
dx
x
∫
1 0
cos
A straightforward Monte Carlo algorithm is to sample x uniformly on[0, 1] and sum the quantity cos(
π
x/2).
Then variance can be estimated and its value is about 0.0947. Let us expand cosine in power series.
4
4
4
2
2
docsity.com
%
Sampling from a Function g(x) = cos(pi*x/2) and
%
find area under f(x)g(x), where,
%
f(x) = 3(1 – xx* ) in interval [0, 1]
const = pi/2; c1 = 1./const; x(1)=0; N(1) = 1000; exact(1)= c1; area(1)=c1;
nbins = 10; nmax = 40;
for jj=1: nmax %%% loop for change in N
rand('state', 0) % initialize
jj N(jj+1) = N(jj) + 1000;
sum1 = 0.0; sum2 = 0.0;
for i=1:nbins %----------------------------- loop begins for nbins
rand('state', i) % initialize icount = 0; sum = 0.0;
for k = 1:N(jj+1) % ------------------- loop for integration
x = rand;
% g = cos(const*x);
% simple way
% sum = sum + g;
% simple way
%
icount = N(jj+1);
% simple way
gg = 2cos(constx)/(3(1-xx));
%importance sampling
if(y <=(1-x^2)) sum = sum + gg;
%importance sampling
icount = icount + 1; end
%importance sampling
end
area(i) = sum/icount; sum1 = sum1 + area(i); sum2 = sum2 + area(i)^2;
end %---------------------------------- loop ends for nbins
avarea(jj+1) = sum1/10.0 ; ava2 = sum2/10.0; var = ava2 - avarea(jj+1)^2; stdev(jj+1) = sqrt(var) ;
exact(jj+1) = c1;
axis([1 50000 0.63 0.65])
errorbar(N,avarea,stdev) plot(N, exact, 'r:.') hold on m(jj)= getframe;
end %%% loop for change in N
MATLAB Program for
Importance
Sampling
Example 1:
docsity.com
12
0
10000
20000
30000
0.644 0.642 0.640 0.638 0.636 0.
Average Area
N
Simple
MC
0
10000
20000
30000
40000
0.6440.6420.6400.6380.6360.
Average Area
N
Using Importance Sampling
Results
Example 1:
docsity.com
Another example on importance sampling:
The variance associated with this procedure is
Again a straightforward Monte Carlo method would be to sample xuniformly on (0, 1) and form the estimator:
dx
x
∫
1 0
2
2
1
1
x
g
−
=
050
.
0
}
var{
1
=
g
To improve the calculations and reduce the variance, the integrandcan be expanded in a power series about its maximum:
L
−
=
2
2 1
1
x
g
docsity.com
From this we infer that a reasonable importance function might be following:
2
The value of b might be chosen to give the minimum variance.
With this choice of h(x),
tanh
var{
2
1
−
g
2
2
1
And its variance is
docsity.com
17
Choice of Importance Function
In a global sense, we want an importance function that matches the general behavior of the integrand at its maximum but also is similarover the whole range of integration. •
In the figure, g is the integrandwe wish to approximate.
The h
1
is importance function
derived from the Taylor seriesexpansion.
It is always greater than g.
The h
2
is a better importance
function because it describe gbetter over the entire range ofintegration.
5
10
15
26 24 22 20 18 16 14 12
g
h
2
h
1
docsity.com
The Procedure:
Let us do this example using MATLAB and explain how to choose the parameter
β
As a first step we run simple MC and find the integral. Its exact valueis
π
/4. We run this for several different values of N and find the
docsity.com
Results of MATLAB Program
1 .0 x 1 0
2 .0 x 1 0
3 .0 x 1 0
m in [v a r{g }] a t
β
v a ria n c e {g }
β
docsity.com
Importance Sampling
0
10000
20000
30000
40000
0.8000.7980.7960.7940.7920.7900.7880.7860.7840.7820.
docsity.com