Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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

Linear Algebra

Authors: Jim Hefferon

1st Edition

978-0982406212, 0982406215

More Books

Students also viewed these Mathematics questions