2. Let $f: [1,3] \rightarrow \mathbb{R}$ be some function whose integral you wish to compute with respect to a\probability density function, $p$, i.e.,
$\mu = \int_1^3 f(x)p(x)dx$,
where $p = \frac{1}{6}(x+2)$. Suppose that it is difficult to generate random variables with PDF $p$,
but easy to generate random variables with PDF $\tilde{p} = \frac{1}{2}$.
a) (15 points) Derive an acceptance-rejection method for generating variables $X_i$ IID $\sim p$
from $\tilde{X}_i$ IID $\sim \tilde{p}$. If you have $X_1 = 1.5765$ and $U_1 = 0.6929 \sim U[0, 1]$, should you accept
$\tilde{X}_1$ to be $X_1$?
b) (15 points) Suppose $f(x) = x^2$, construct an estimate of $\mu$ using importance sampling
with $X_1, \dots, X_4$ IID $\sim p$. You can generate $\tilde{X}_i$ by the following IID uniform random
numbers $U_i \sim U[0, 1]$:
$\begin{array}{c|cccc}
i & 1 & 2 & 3 & 4 \\ \hline U_i & 0.4914 & 0.2845 & 0.0733 & 0.7632 \\end{array}$