Solve the following problem:
In both questions, the comparison between generators is understood in terms of efficiency via the system. time function.
a. Generate a binomial Bin(n, p) random variable with n = 25 and p = .2. Plot a histogram for a simulated sample and compare it with the binomial mass function. Compare your generator with the R binomial generator.
b. For α ∈ [0, 1], show that the R code
> u=runif(1)
> while(u > alpha) u=runif(1)
> U=u
produces a random variable U from U([0, α]). Compare it with the transform αU, U ∼ U(0, 1), for values of α close to 0 and close to 1, and with runif(1,max=alpha).