Question: Exercise 3 : ( 6 points ) . Let the random variable X follow a distribution with density e kappa cos ( x )
Exercise : points Let the random variable X follow a distribution with density ekappa cosx fxpi Ikappa if x in pi pi otherwise where kappa is a parameter and I is the modified Bessel function of the first kind of order For this exercise, you will need to use the rejection sampling algorithm with a proposal that you deem appropriate. a Derive mathematically the expected number of draws C until we accept. This C can be a function of the parameter kappa b Write a function in R that employs the rejection algorithm with the candidate density that you have used in Part a in order to simulate n samples this will be given by the user from the distribution with the density in Equation for kappa also given by the user they know that it should be a positive number and no further tests are required in your function The function should also return the total number of draws. c Test your function for n by generating a histogram of the output and by comparing the histogram with the target density. d Notice the total number of draws in Part c of the exercise. Does this seem to agree with the results from Part a of the exercise
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
