Solve the following problem:
The rather strange density
f(x) ∝ exp(-x2/2) {sin(6x)2 + 3 cos(x)2 sin(4x)2 +1}
can be generated using the Accept-Reject algorithm.
a. Plot f(x) and show that it can be bounded by Mg(x), where g is the standard normal density
g(x) = exp(-x2/2) / √2π
Find an acceptable if not necessarily optimal value of M.
b. Generate 2500 random variables from f using the Accept-Reject algorithm.
c. Deduce from the acceptance rate of this algorithm an approximation of the normalizing constant of f, and compare the histogram with the plot of the normalized f.