Question: Exercise 3 : ( 6 points ) . Let the random variable X follow a distribution with density e kappa cos ( x )

Exercise 3: (6 points). Let the random variable X follow a distribution with density e\kappa cos(x) f(x)=2\pi I0(\kappa ), if x in [\pi ,\pi ]0,, otherwise (0.1) where \kappa >0 is a parameter and I0() is the modified Bessel function of the first kind of order 0. 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 (0.1) 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 =10,000) 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 blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!