Question: Exercise 2 Rejection method [10 points] Sample from the following probability density p(x) = 2 2 e x 2/2 for x 0 (and 0 otherwise)

Exercise 2 Rejection method [10 points] Sample from the following probability density p(x) = 2 2 e x 2/2 for x 0 (and 0 otherwise) using the rejection method. (i) Plot p(x) in the range [0, 4] (ii) First put p(x) into an appropriate rectangular box and use the rejection method as we did during the lab. Produce N = 10000 random numbers distributed according to p(x) and plot their histogram together with p(x). Calculate the efficiency of this method (average number of tries for each successfully generated number). (iii) You can achieve much better efficiency (and won't need a cutoff) if you use f(x) = 2e x as comparison function. Plot p(x) and f(x) together in one plot. You should see that f(x) is always above p(x). (iv) Use the rejection method again (as we did during the lab), but this time generating uniform random points under f(x) rather than inside the rectangular box. Since f(x) is exponential you can use a library to generate the x-values. Alternatively you can use the transformation method or the general rejection method, as shown in the lectures. As before, produce N = 10000 random numbers distributed according to p(x)

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 Mathematics Questions!