Question

#3.7

distribution. 0 and check that the mode of the generated samples is close to the (check the histogram). theoretical mode mass

0 0
Add a comment Improve this question Transcribed image text
Answer #1

3.7) Acceptance-Rejection Algorithm for continuous random variables .

1. Generate a RV Y distributed as 7.

2. Generate U (independent from Y )

3. If fy (Y) cgy (Y) , then set X Y(accept) ; otherwise go back to 1, (“reject”).

Take Y~U(1) . Then gy 1;0y<1 .

The Beta density is

(3+2) fx (X) (3)r(2)(1 -x)1 x (x) 12x2(1-x); 0 < x <1
To find the maximum value of , x (x) 12x2(1 - x) gy (x) is found by differentiating,

(1 -x) 0 - x) = 0 dx 2x(1 x)2 - x2 0 2(1 x) x 0 x = 2/3

Thus,

c=12(2/3)^2(1-2/3)=16/9

The Histogram and theoretical density are plotted below.

Histogram of Beta Distribution 0.0 0.2 0.4 0.6 0.8 1.0 X 00 O L Density

The complete R code below.

N <- 1000
c <- 16/9
n <- 1
X <- array(dim = N)
f<- function (x)
{
12*x^2*(1-x)
}
while(n<=N)
{
Y <- runif(1)
U <- runif(1)
if(U < f(Y)/c)
{
X[n] <- Y
n <- n+1
}
}

plot(1:1)
dev.new()
hist(X,prob = TRUE, col = "skyblue", main = "Histogram of Beta Distribution")
curve(dbeta(x,3,2),add=TRUE,lwd=2,col="blue")

Add a comment
Know the answer?
Add Answer to:
#3.7 distribution. 0 and check that the mode of the generated samples is close to the...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT