Solution (source code)

= Solution

Use the same acceptance <indicator functions> and set $K_n=\sum_{i=1}^nA_i$, $S_n=\sum_{i=1}^nA_i\phi(Y_i)$. The <rejection sampling> estimator based on these $n$ proposals is the mean over the accepted observations:
$$
\boxed{\widehat\theta_n^{\mathrm{RS}}=\frac{S_n}{K_n}\quad(K_n>0).}
$$
For $K_n=0$, any fixed convention, such as zero, is harmless asymptotically. The $A_i$ are <independent and identically distributed random variables> with <Bernoulli distribution> and success <probability> $1/M$, so the <strong law of large numbers> gives $K_n/n\to1/M$ <almost surely>. In particular $K_n>0$ eventually <almost surely>. The exact identity
$$
\boxed{\widehat\theta_n^{\mathrm{IS}}=\frac{MK_n}{n}\widehat\theta_n^{\mathrm{RS}}}
$$
then holds whenever $K_n>0$. Wherever $S_n\ne0$, it follows that
$$
\frac{\widehat\theta_n^{\mathrm{IS}}}{\widehat\theta_n^{\mathrm{RS}}}
=\frac{MK_n}{n}\longrightarrow1\quad\text{almost surely}.
$$
A qualification is missing from the printed claim: the quotient must be defined eventually. A convenient sufficient assumption is $\mathbb E_p|\phi|<\infty$ and $\theta\ne0$. Indeed, another application of the <strong law of large numbers> gives $S_n/n\to\theta/M$, ensuring that $S_n$ is eventually nonzero. This proves the stated quotient limit under that assumption.

As printed, the assertion is false as a universally defined quotient. For example, $\phi\equiv0$ makes both estimates zero for every $n$. Even excluding that example is insufficient: take $p=q$ to be the <uniform distribution> on $(0,1)$, $M=1$, and $\phi(y)=1$ for $y<1/2$ and $-1$ otherwise. Then $S_n$ is a <simple symmetric random walk>, which returns to zero infinitely often <almost surely>, leaving the quotient undefined infinitely often.

With integrability but no assumption $\theta\ne0$, the exact multiplicative identity remains valid, and both estimates converge to $\theta$ <almost surely>. In particular $\widehat\theta_n^{\mathrm{IS}}-\widehat\theta_n^{\mathrm{RS}}\to0$ <almost surely>. One may alternatively define the quotient's removable $0/0$ cases as $MK_n/n$; that explicitly extended quantity always converges to one. These are valid repairs of the source's unrestricted statement.