Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The truncated gamma distribution has the following density: For X TG ( , , a ) , Xhasthefollowingdensity f ( x ) = C x

The truncated gamma distribution has the following density:

ForXTG(,,a),Xhasthefollowingdensity

f(x)=Cx1exp(x),forxa

and f(x) = 0 for all x < a

In R, you can use the function pgamma() (cdf of gamma distribution) to find the normalizing

constant C. For example, if = 4, = 3, a = 2, then using

C <- 1 / (1 - pgamma(2, shape=4, rate=3)) * 3^4/gamma(4)

we can nd that C = 89:283 for TG(4; 3; 2). Here 3^4= gamma(4) calculates the normalizing constant in the Gamma(,) density.

Assume that we can only sample from Uniform(0, 1). Consider the rejection sampling

from TG(3, 2, 2)

(i) (5 marks) Consider the naive rejection sampling using Gamma(3, 2) as a proposal distribution. In this case, the rejection sampling reduces to sampling X's from Gamma(3, 2)

and then only accept those X's that exceed a = 2. Write down the full algorithm in

steps. Implement this rejection sampling algorithm in R and draw n = 10^4 samples from

TG(3, 2, 2). Draw a histogram and superpose the true density f(x) to your histogram.

(Hint: You can use the R functions pgamma() and dgamma() for this question. You can

superpose the density curve using lines(), after you run hist().)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Discrete Mathematics, Revised

Authors: Seymour Lipschutz, Marc Lipson

3rd Edition

0071615873, 9780071615877

More Books

Students also viewed these Mathematics questions