00:01
We are asked to simulate the distribution with the pdf shown here using the accept -reject method with a uniform candidate distribution on 0 to 3.
00:12
For part a, we are asked to find the majorization constant c.
00:18
This is the constant such that f at x over g at x is always smaller than it.
00:31
Now, g at x is the uniform distribution on 0 to 3, so its pdf is given by 1 over 3.
00:47
Then f at x over g at x is therefore 4 over 9 times x squared times 3 minus x.
01:05
So we want to find the smallest value of c such that this expression is always at most c.
01:15
So in other words we want to find the maximum value that this expression can take.
01:21
So we can use calculus to find that.
01:23
It's where the derivative is equal to 0.
01:39
And if we solve for x, we get two possibilities.
01:42
One is x equal to zero, except that is on the boundary of the domain for x.
01:49
So it is not admissible.
01:50
And the other is x is equal to 2.
02:09
And so what we get is c is equal to 19 over 6.
02:18
Then for part b, we were asked to write a program that simulates values from the distribution.
02:28
So remember the three steps of the process using the accept -reject method are first, we draw a random variable from g, then we draw a random variable from the uniform distribution, the standard uniform distribution.
02:49
And then our acceptance criterion is if the uniform variant times c times the variant drawn from the pdf g of y is less than or equal to f at y, then we accept it.
03:27
And so the code that i've made in r is as follows.
03:33
So we have step one where we generate a random draw from y, which is the uniform distribution on 0 to 3.
03:45
Second step we draw from the standard uniform distribution.
03:50
And 3 we check our acceptance criterion.
03:55
If it meets the criterion, then we accept y into our vector x.
04:02
So that after the program is finished running, x will be a vector of 10 ,000...