concept MH in category probabilistic programming

This is an excerpt from Manning's book Practical Probabilistic Programming.
Unfortunately, if you naively apply MH to this problem, it won’t work at all. The problem is this: In a possible world with positive probability, exactly one appearance has an award. You want MH to explore the space of possible worlds with high probability. If you start in one possible world in which one appearance has an award, you want to move to another state in which this appearance doesn’t have an award and exactly one other appearance has an award. Figure 11.12 shows why this won’t happen. The figure shows the Bayesian network for a case with two actors, movies, and appearances, but the same problem holds with any number. Under the default proposal scheme, a proposal could change the fame of a single actor, the quality of a single movie, or the award of a single appearance. Changing the fame of an actor or quality of a movie is fine. But if the current state satisfies the unique award condition, changing the award of a single appearance will necessarily violate that condition. If you change the award of the appearance that currently has an award, you’ll move to a state where zero appearances have an award; if instead you change the award of an appearance that currently doesn’t have an award, you’ll move to a state where two appearances have an award. In either case, the new state violates the condition and will be rejected. There’s no way to switch the award from one appearance to the other in a single MH step.
Figure 11.12. Possible single-step proposals for the naïve application of MH to the actors and movies example. Variables are shown in rounded rectangles. For each variable, the current value is to the left of the arrow, and possible alternative values are to the right. Under the default proposal scheme, in a single step, MH can change any one of the variables from the current value to a different value. Two values can’t be changed simultaneously. Therefore, any proposal that changes the value of an award variable will violate the unique awards condition, so it won’t be accepted.
![]()
How do you get MH to work on this problem? There are two main ideas. The first is to use proposal schemes that are different from the default scheme. These custom schemes can, for example, propose to change two elements at once. The second idea is to avoid hard conditions that can never be violated. One of the problems in our example is that the unique award condition absolutely has to be satisfied for a proposal to be accepted. If you could relax this and sometimes accept proposals with zero or two awarded appearances, the MH algorithm would occasionally be able to change an award. The next two subsections elaborate on these two ideas.
Point 3 indicates that if the Markov chain is designed so that the stationary distribution is the posterior distribution from which you want to sample, you get the basis of an algorithm to sample from the posterior distribution. There are many ways to design a Markov chain with this property. Figaro’s MCMC algorithm uses one approach, based on an algorithm known as Metropolis-Hastings (MH). MH is a widely used algorithm because of its general applicability, which also makes it suitable for probabilistic programming, with its ability to express many kinds of models.