A posterior we cannot normalize
The topic Monte Carlo and Markov chains gave us two tools. A Monte Carlo average turns an expectation into a sum over samples. A Markov chain whose stationary distribution is produces such samples, once we discard the burn-in and account for autocorrelation. What that topic did not say is how to build a chain whose stationary distribution is our posterior. This topic gives two recipes: Metropolis–Hastings, which works for almost any posterior, and Gibbs sampling, which needs no tuning when the conditionals are standard distributions.
The obstacle is always the same. In
we can evaluate the numerator at any , but the evidence is an integral. Call the numerator the unnormalized posterior:
The running example is the coin from the topic The Bayesian approach: three flips, three heads. There a Beta prior made the posterior a one-liner. Now put the prior on the log-odds instead, as logistic regression does: is the probability of heads and . The likelihood of three heads is , so
No conjugate family covers this, and has no closed form. Numerical integration in one dimension still works, and it says ; we will use it to check the samplers. In twenty dimensions a grid would be hopeless.
The way out is that some quantities do not need at all. Both algorithms below are built only from those.
A note on letters. The chain's state is written and the target with an unknown ; for a posterior, and . The data stay .