Solution (source code)

= Solution

For any measurable set $A$, integrating the joint acceptance event in <rejection sampling> gives
$$
P(Y\in A,\text{accept})=\int_Ag(y)\frac{f(y)}{Cg(y)}\,dy=\frac1C\int_Af(y)\,dy.
$$
Setting $A$ equal to the whole support yields $P(\text{accept})=1/C$. Thus
$$
\boxed{P(Y\in A\mid\text{accept})=\int_A f(y)\,dy.}
$$
To verify repeated attempts directly, the <probability> that the first accepted observation falls in $A$ is
$$
\sum_{r=1}^{\infty}(1-1/C)^{r-1}\frac1C\int_A f(y)\,dy=\int_A f(y)\,dy.
$$
With finite $C$, eventual acceptance has <probability> one. Applying the same argument after each success proves that the retained sequence consists of independent draws from the target.