[step:Compute the accepted law for one proposal]Let $Y:(\Omega,\mathcal F)\to(E,\mathcal E)$ be an $E$-valued [random variable](/page/Random%20Variable) with density $q$ with respect to $\mu$, and let $U:(\Omega,\mathcal F)\to((0,1),\mathcal B((0,1)))$ be independent of $Y$ with distribution $\operatorname{Unif}(0,1)$. Define the event $A\in\mathcal F$ by
\begin{align*}
A=\{U\le a(Y)\}.
\end{align*}
First observe that $p=0$ $\mu$-almost everywhere on the measurable set $\{x\in E:q(x)=0\}$. Indeed, on the full-measure set where $p\le Mq$, the condition $q(x)=0$ implies $0\le p(x)\le0$. Hence, for $\mu$-almost every $x\in E$,
\begin{align*}
q(x)a(x)=\frac{p(x)}{M}.
\end{align*}
Let $N\in\mathcal E$ be a $\mu$-null set outside which $p\le Mq$. Then $0\le a(x)\le1$ for every $x\in E\setminus N$ with $q(x)>0$, while $a(x)=0$ on $\{q=0\}$. Since
\begin{align*}
\int_N q(x)\,d\mu(x)=0,
\end{align*}
the exceptional set has zero mass under the proposal measure $q\,d\mu$.
Let $B\in\mathcal E$. Let $\mathcal L^1$ denote one-dimensional [Lebesgue measure](/page/Lebesgue%20Measure) on $(0,1)$, and let $\nu$ denote the proposal probability measure on $(E,\mathcal E)$ defined by
\begin{align*}
\nu(C)=\int_C q(y)\,d\mu(y)
\end{align*}
for $C\in\mathcal E$. Since $Y$ has density $q$ and $U$ is independent of $Y$, the joint law of $(Y,U)$ on $E\times(0,1)$ is $\nu\otimes\mathcal L^1$. Equivalently, this joint law has density $(y,u)\mapsto q(y)$ with respect to $\mu\otimes\mathcal L^1$. Integrating the indicator of the measurable set $\{(y,u)\in B\times(0,1):u\le a(y)\}$ against this product law gives
\begin{align*}
\mathbb P(Y\in B,A)=\int_B\int_0^1 \mathbb 1_{\{u\le a(y)\}}q(y)\,d\mathcal L^1(u)\,d\mu(y).
\end{align*}
For every $y\in E\setminus N$, the inner integral equals $a(y)$ because $0\le a(y)\le1$. Since $N$ has zero mass under $q\,d\mu$, changing the value of the inner integral on $N$ does not change the outer integral. Thus
\begin{align*}
\mathbb P(Y\in B,A)=\int_B q(y)a(y)\,d\mu(y).
\end{align*}
Using $q a=p/M$ $\mu$-almost everywhere gives
\begin{align*}
\mathbb P(Y\in B,A)=\frac{1}{M}\int_B p(y)\,d\mu(y).
\end{align*}[/step]