00:01
We are asked to simulate the distribution with the pdf shown here using the accept slash reject method with a uniform random variable on 0 to 1.
00:12
So the uniform distribution on 0 to 1, we'll call that g of x, is equal to 1, and x goes from 0 to 1.
00:29
Now for part a, we're asked to find the smallest constant c, such that f at x over g at x is always at most c.
00:45
So f at x over g at x is equal to simply f at x since j at x is 1.
01:04
And this must always be less than c.
01:10
Now the biggest that this function becomes is when x is equal to 0.
01:15
In that case it equals 3 over 2.
01:21
So we will set c equal to 3 over 2.
01:25
That's the smallest constant such that f at x over g at x is always less than c.
01:34
And then in part b we are asked to write a program.
01:36
To simulate values from this distribution.
01:40
Now first recall the steps of the accept -reject method.
01:50
Step 1 is to generate a variant from the function g.
02:02
2 is to generate a uniform variant.
02:14
And then for step 3, so if the uniform variant times the variant from the function g times our constant c is less than or equal to the function at a function at a function at a function y, and this is the function f at y, then we accept x.
02:50
We accept y as x.
02:59
And we keep repeating these three steps until we have the number of simulated values that we want.
03:07
So the r code that can achieve this is shown here.
03:14
So here we are performing step one.
03:17
This is step two, and this is step three.
03:22
If y is accepted as x, then the vector x gets populated with y.
03:27
At the ieth index...