I did not fully understand the proof of the acceptance probability.
The acceptance-rejection algorithm is described as follows:
- suppose you have RVs $X$ and $Y$ with densities $f$ and $g$, respectively, and there exists a constant $c$ such that $\frac{f(t)}{g(t)} \leq c$ for all $t$ such that $f(t) > 0$, then
- generate random $y$ from distribution with density $g$
- generate random $u$ from $\text{Uniform}(0, 1)$
- if $u < \frac{f(y)}{cg(y)}$ accept $y$ and deliver $x = y$, otherwise repeat
In Rizzo's book 'Statistical Computing with R' (p56) he writes
$P(\text{accept}|Y)=P(U<\frac{f(Y)}{cg(Y)}|Y)=\frac{f(Y)}{cg(Y)}$
and so
$\sum_y{P(\text{accept}|y)P(Y=y)}=\sum_y{\frac{f(y)}{cg(y)}g(y)}=\frac{1}{c}$
This still makes sense to me, but what about the continuous version of this proof, which is as follows:
$ \begin{aligned} P(A) =& \int_{-\infty}^{\infty}dy\int_0^{\frac{f(y)}{cg(y)}}g(y)du \\ =& \int_{-\infty}^{\infty}\frac{1}{c}f(y)dy \\ =& \frac{1}{c}. \end{aligned} $
Could someone explain to me specifically how you get to this double integral?