Run Example 4.4 and generate 1000 random variables. Determine the number of variates that were rejected and the total number generated to obtain the random sample. What percentage were rejected? How efficient was it?
Example 4.4
We shall illustrate the acceptance-rejection method by generating random variables from the beta distribution with parameters α = 2 and β = 1 [Ross, 1997]. This yields the following probability density function:
Since the domain of this density is 0 to 1, we use the uniform distribution for our We must find a constant that we can use to inflate the uniform so it is above the desired beta density. This constant is given by the maximum value of the density function, and from Equation 4.7, we see thatc= 2. For more complicated functions, techniques from calculus or the MATLAB function fminsearch may be used. The following MATLAB code generates 100 random variates from the desired distribution. We save both the accepted and the rejected variates for display purposes only.
In Figure 4.3, we show the accepted and rejected random variates that were generated in this process. Note that the accepted variates are those that are less thanf().
Already registered? Login
Not Account? Sign up
Enter your email address to reset your password
Back to Login? Click here