Conjugate Priors & Exact Posteriors
Beta–binomial, normal–normal and Dirichlet–multinomial.
For a handful of models, Bayesian inference needs no integrals and no sampling: the posterior has the same form as the prior, and updating means adding counts. This lesson works out the four conjugate pairs that matter most, their predictive distributions and what they teach about shrinkage, and then asks the deeper question of why a prior should exist at all, which de Finetti's theorem answers.
What you’ll learn
- Define conjugacy, construct the conjugate prior of an exponential family, and read hyperparameters as pseudo-observations.
- Derive the Beta–binomial posterior and predictive distributions, and quantify shrinkage toward the prior mean.
- Derive the normal–normal posterior by completing the square, and state the normal–inverse-gamma update with its Student- marginals.
- Use the Dirichlet–multinomial and Gamma–Poisson models for counts, connecting them to additive smoothing and overdispersion.
- State de Finetti's theorem for exchangeable sequences and explain why it fails for finite sequences.
Conjugacy, precisely
| Likelihood | Conjugate prior | Posterior after observations | Predictive for a new observation |
|---|---|---|---|
| Bernoulli / binomial, | Bernoulli with mean ; beta-binomial for trials | ||
| , known | , precisions add | ||
| , both unknown | normal–inverse-gamma | normal–inverse-gamma | Student |
| categorical / multinomial, | categorical with ; Dirichlet-multinomial for several draws | ||
| Poisson, rate | (rate ) | negative binomial | |
| , both unknown | normal–inverse-Wishart | normal–inverse-Wishart | multivariate Student |
Conjugacy is a convenience, not a law of nature: it buys closed forms and instant updates at the price of a restricted prior shape. When the prior shape genuinely matters, or the model is not an exponential family, the posterior must be computed numerically (Approximate Inference). Conjugate models remain the workhorses of streaming and online problems, such as the Beta posteriors behind Thompson sampling in bandits and the Gaussian updates inside the Kalman filter.
Beta–binomial: shrinkage and prediction
With prior and heads in flips, the posterior mean is . Subtracting the MLE gives the exact size of the pull toward the prior mean :
The prior's strength acts as a sample size: when , the posterior mean sits exactly halfway between the prior mean and the MLE.
Prior , a coin whose MLE settles near . About how many flips does it take before the posterior mean is within of the MLE?
Show the answer
600 flips
Solve : , so . A prior worth 200 imaginary flips needs three times that many real flips before the data win by this criterion.
The probability of heads in future flips averages the binomial over the posterior , with and :
Its mean is that of a binomial with , but its variance is inflated by uncertainty about :
Example: a flat prior and 9 heads in 10 flips give . The chance that the next two flips are both heads is , between the squared posterior mean and the plug-in .
Gaussian models: precisions add
Data with known, and prior . The log-posterior is a quadratic in :
Complete the square. Precisions add, and the posterior mean is the precision-weighted average of the prior mean and the sample mean:
A new observation is with independent , so its predictive variance adds noise and parameter uncertainty, and only the second shrinks with :
Prior , noise variance , and observations with mean . What is the posterior mean of ?
Show the answer
1.5
The data's precision is , equal to the prior's precision , so the posterior mean is halfway: , with posterior variance . The predictive variance of a new observation is .
| Quantity | Prior | Posterior |
|---|---|---|
| variance | , | |
| mean given variance | , | |
| mean, variance integrated out | Student | |
| new observation | Student |
Counts: Dirichlet–multinomial and Gamma–Poisson
Categories. With a Dirichlet prior , density , and counts , the posterior is . The predictive probability of category is the posterior mean , where : additive smoothing, with (Laplace) or (Jeffreys' prior for the multinomial) as common defaults. Predicting a whole sequence this way is a Pólya urn: draw a ball, put it back with one more of the same color, and the urn's composition is the current posterior.
Rates. With a Gamma prior , density , and Poisson counts , the posterior is : prior events observed over prior time units. The predictive distribution of a new count is negative binomial, with mean and variance , larger than its mean. A Gamma mixture of Poissons is overdispersed, which is why the negative binomial is the standard model for counts that vary more than a Poisson allows.
A three-sided die has a prior and shows counts in 8 rolls. What predictive probability does the unseen face get?
Show the answer
B.
The posterior is , and the predictive probability of face 2 is . With Jeffreys' it would be : the prior's strength sets how much probability unseen outcomes keep.
Think first Prior for a daily event rate; you then observe 3, 5 and 4 events on three days. What are the posterior mean and the predictive variance of tomorrow's count?
The posterior is , with mean : between the prior mean 2 and the sample mean 4, with weight on the data. Tomorrow's count is negative binomial with mean and variance . The extra over a Poisson's variance is your remaining uncertainty about .
Exchangeability and de Finetti
Where does the prior come from? A sequence is exchangeable if the joint law of every finite prefix is unchanged by permuting its terms: the order of the observations carries no information. That is weaker than independence, and it is often all you are willing to assume.
Read it as a justification of the Bayesian model. Exchangeability alone implies that the data behave as if a parameter were drawn from a prior and the observations were then i.i.d. given . The parameter is not a mystical quantity: it is the long-run frequency, and the prior is your belief about that frequency.
The theorem needs an infinite sequence. Draw both balls, without replacement, from an urn holding one red and one black: is or with probability each, which is exchangeable, yet . Any mixture of i.i.d. sequences has , while here the covariance is . Diaconis & Freedman (1980) quantified the gap: the first terms of an exchangeable sequence of length over a finite set are within total variation distance of order of a mixture of i.i.d. sequences.
Key takeaways
- A conjugate prior keeps the posterior in the prior's family; for exponential families it is and the hyperparameters are pseudo-data.
- Beta–binomial: the posterior mean shrinks the MLE toward the prior mean by the factor , and the beta-binomial predictive has the binomial's mean with inflated variance.
- Normal–normal: precisions add and the posterior mean is precision-weighted; with an unknown variance (normal–inverse-gamma) the marginal posterior and the predictive are Student .
- Dirichlet–multinomial gives additive smoothing and the Pólya urn; Gamma–Poisson gives a negative-binomial predictive, overdispersed relative to the Poisson.
- de Finetti: an infinite exchangeable binary sequence is a mixture of i.i.d. Bernoulli sequences, so the prior is a belief about a long-run frequency. Finite exchangeable vectors need not be mixtures, but nearly are when .
Check yourself
In the interactive lesson these are scored with your confidence, and what you miss comes back for review.
A prior with meets data with MLE . After how many observations is the posterior mean exactly halfway between the prior mean and ?
- 15
- 30
- 60
- It is never exactly halfway
Show the answer
B. 30
The weight on the data is , which equals when . The prior's strength is literally a sample size.
Prior ; one observation with known noise variance . What is the posterior?
Show the answer
C.
The two precisions are equal ( each), so the posterior mean is the plain average, 13, and the precisions add to : posterior variance 2. Combining information always reduces the variance in this model.
is exchangeable with . What can you conclude?
- It cannot be the beginning of an infinite exchangeable sequence: mixtures of i.i.d. sequences have nonnegative covariance
- It is not exchangeable after all, because exchangeable variables must be independent
- It must be i.i.d., because exchangeability implies independence for pairs
- Nothing: de Finetti's theorem covers every exchangeable vector
Show the answer
A. It cannot be the beginning of an infinite exchangeable sequence: mixtures of i.i.d. sequences have nonnegative covariance
If it extended to an infinite exchangeable sequence, de Finetti would make it a mixture of i.i.d. sequences, whose covariance is . Sampling without replacement produces exactly such negatively correlated, non-extendable exchangeable vectors.
Further reading
- A. Gelman, J. B. Carlin, H. S. Stern, D. B. Dunson, A. Vehtari & D. B. Rubin, Bayesian Data Analysis, 3rd ed. (CRC Press, 2013), chapters 2–3.
- P. Diaconis & D. Ylvisaker, "Conjugate priors for exponential families," Annals of Statistics 7(2), 269–281 (1979).
- B. de Finetti, "La prévision : ses lois logiques, ses sources subjectives," Annales de l'Institut Henri Poincaré 7(1), 1–68 (1937).
- P. Diaconis & D. Freedman, "Finite exchangeable sequences," Annals of Probability 8(4), 745–764 (1980).
- B. Efron & C. Morris, "Data analysis using Stein's estimator and its generalizations," Journal of the American Statistical Association 70(350), 311–319 (1975).