Solution (source code)

= Solution

Restrict to the positive-weight support. From a state $\theta$, propose $\theta'$ according to $q(\theta,\theta')$ and accept with probability
$$
\alpha(\theta,\theta')=\min\left(1,\frac{w(\theta')q(\theta',\theta)}{w(\theta)q(\theta,\theta')}\right).
$$
Otherwise stay at $\theta$. For distinct states, the accepted transition kernel satisfies
$$
\pi(\theta)P(\theta,\theta')=\min\{\pi(\theta)q(\theta,\theta'),\pi(\theta')q(\theta',\theta)\}=\pi(\theta')P(\theta',\theta).
$$
Thus <detailed balance> holds, and summing over $\theta$ proves stationarity. Irreducibility of the accepted kernel makes this <stationary distribution> unique. Proposal irreducibility by itself is insufficient if proposed edges have zero reverse probability and are always rejected.

For convergence of the distribution from an arbitrary start, also require aperiodicity, which can always be supplied by making the chain lazy. In a finite irreducible aperiodic chain, some power $P^m$ has all entries positive. Its rows then share a fixed positive probability component, so repeated application contracts total variation distance geometrically. This proves that the chain's distribution approaches $\pi$.

The stronger fact needed for averages is
$$
\boxed{\frac1M\sum_{j=1}^Mh(\Theta_j)\longrightarrow\sum_\theta\pi(\theta)h(\theta)\quad\text{almost surely}.}
$$
One can justify this directly by returns to a chosen state. Successive excursions are independent identically distributed cycles by the <Strong Markov property>. In a finite irreducible chain, return times have finite mean: from every state there is a path of uniformly bounded length and uniformly positive probability to the chosen state, giving a geometric tail bound. Apply the <strong law of large numbers> to cycle lengths and accumulated rewards. Their ratio converges; the mean visits per cycle, normalized by the mean cycle length, form a <stationary distribution> and hence equal $\pi$. The unfinished final cycle is negligible. This proves the displayed average law, even when the chain is periodic. \b[Under these conditions, Metropolis–Hastings delivers the required posterior expectations.]