Solve the following problem:
Consider the target as the G(α, β) distribution and the candidate as the gamma G([ α], b) distribution (where [a] denotes the integer part of a).
a. Derive the corresponding Accept-Reject method and show that, when β = 1, the optimal choice of b is b = [ α]/α.
b. Generate 5000 G(4, 4 / 4.85) random variables to derive a G(4.85, 1) sample (note that you will get less than 5000 random variables).
c. Use the same sample in the corresponding Metropolis-Hastings algorithm to generate 5000 G(4.85, 1) random variables.
d. Compare the algorithms using (i) their acceptance rates and (ii) the estimates of the mean and variance of the G(4.85, 1) along with their errors.
(Hint: Examine the correlation in both samples.)