Skip to content
BIASED

Conjugate priors and the exponential family

Block 1 of 8~2 min

When the integral takes care of itself

In the topic The Bayesian approach a coin with a uniform prior on θ\theta came up heads three times, the posterior became Beta⁡(4,1)\operatorname{Beta}(4, 1), and the next flip was predicted to be heads with probability 4/54/5. Everything there had a closed form. That was luck, not the rule. Bayes' formula

p(θ∣X)=p(X∣θ) p(θ)∫p(X∣θ′) p(θ′) dθ′p(\theta \mid X) = \frac{p(X \mid \theta)\, p(\theta)}{\int p(X \mid \theta')\, p(\theta')\, d\theta'}

has an integral in the denominator, and for most pairs of prior and likelihood nobody can take it by hand. A grid is no escape either: with GG points per axis and dd parameters it costs GdG^d evaluations, and 100100 points for 55 parameters is already 101010^{10}.

This topic is about the pairs where the integral takes care of itself.

Definition. A family of priors p(θ∣λ)p(\theta \mid \lambda) with hyperparameters λ\lambda is conjugate to a likelihood p(x∣θ)p(x \mid \theta) if, for any admissible data XX, the posterior stays in the family:

p(θ∣X,λ)=p(θ∣λ′),p(\theta \mid X, \lambda) = p(\theta \mid \lambda'),

where the new hyperparameters λ′\lambda' are computed from λ\lambda and XX.

Three remarks keep the definition honest.

  • The family is shared by the prior and the posterior only. The likelihood is a distribution over the data, often on a different space. As a function of θ\theta it just has to look like the prior, so that the product keeps the form.
  • Bayesian updating turns into arithmetic on a few numbers. The normalizer of the family is known, so the evidence and the predictive often come out in closed form too.
  • If the observations are independent given θ\theta, then p(X∣θ)=∏ip(xi∣θ)p(X \mid \theta) = \prod_i p(x_i \mid \theta). Yesterday's posterior is today's prior, λ→λ′→λ′′\lambda \to \lambda' \to \lambda'', and neither the order nor the batching of the data changes the result.

How do you find a conjugate prior? Write the likelihood as a function of θ\theta, drop the factors that do not depend on θ\theta, and take a prior of the same shape. The next blocks do exactly this four times.

Answers are saved on the server and tied to this browser until you sign in.