0% found this document useful (0 votes)
49 views1 page

Lab 10, Monte Carlo Integration: Topics

This document provides an overview of Monte Carlo integration and outlines tasks to use simulation methods to estimate properties of the Gamma(2,1) distribution, including its median. Specifically, it will: 1) Generate 1000 observations of a Gamma(2,1) random variable through rejection sampling. 2) Compare a histogram of the observations to the theoretical Gamma(2,1) probability density function. 3) Estimate the median of the Gamma(2,1) distribution from the sample. 4) Use Monte Carlo integration on 5000 new samples to estimate the area under the Gamma(2,1) curve between 0 and the estimated median.

Uploaded by

Glass-Half-Empty
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
49 views1 page

Lab 10, Monte Carlo Integration: Topics

This document provides an overview of Monte Carlo integration and outlines tasks to use simulation methods to estimate properties of the Gamma(2,1) distribution, including its median. Specifically, it will: 1) Generate 1000 observations of a Gamma(2,1) random variable through rejection sampling. 2) Compare a histogram of the observations to the theoretical Gamma(2,1) probability density function. 3) Estimate the median of the Gamma(2,1) distribution from the sample. 4) Use Monte Carlo integration on 5000 new samples to estimate the area under the Gamma(2,1) curve between 0 and the estimated median.

Uploaded by

Glass-Half-Empty
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

Lab 10, Monte Carlo Integration

Familiarise yourself with the following MatLab Functions:


exp(); rand(); mean(); std(); var(); median(); quantile();
histogram(); plot(); if-then-else; while;

Topics
The Gamma distribution, Gamma(k, ), is a generalisation of the exponential distribution (this is because
Gamma(1, ) = E()). The pdf of Gamma(k, ) is given by
( k

xk1 ex : if x 0
f (x) = (k)
0 : otherwise.

If X Gamma(k, ), then the expectation and variance of X are given by E[X] = k and V[X] = k2
respectively. Note that, for positive integers k, (k) = (k 1)!. The function (k) can be evaluated with
the MatLab command: gamma(k).

Tasks
Consider X Gamma(2, 1). We will use simulation methods to see what the median of X is.

1. Create a MatLab function for evaluating f (x). Use your function to plot the pdf of X.
2. We are going to perform rejection sampling on Gamma(2, 1). Let the proposal distribution be the
uniform distribution, U(a, b), with a pdf of g(x). The lower bound of this interval should be a = 0.
Select a reasonable upper bound, b, for this interval so that P(X > b) is neglectably small (choose b so
that f (x) < 0.0005 for all x > b). Write down the pdf function g(x).

3. For your interval, [0, b], select the smallest possible value m such that f (x) < mg(x) for all 0 x b.
4. Perform rejection sampling to generate 1000 observations from the distribution Gamma(2, 1). How
many times did your algorithm sample from U(a, b)?
5. Plot a histogram of your 1000 observations. Plot the pdf of Gamma(2, 1) on the same set of axes and
compare it to the histogram.
6. Calculate the sample mean and sample variance of your 1000 observations. Are they close to the
population mean and population variance?
, for the median of X.
7. Use your sample to compute an estimate, M
]) to estimate the area under
8. Perform MC integration (using 5000 new samples on the interval [0, M

the Gamma(2, 1)-curve between 0 and M . How close is your estimate to 0.5?

You might also like