05. Bayesian Inference and Conjugate Priors — How Distributions Learn
Background 5/5. So far, distributions have been treated as "given." This page covers the procedure for updating beliefs about a distribution after observing data (Bayesian inference) and the special structure that gives this update a closed form (conjugacy). This is where the Beta distribution takes the stage as a "probability distribution over probabilities."
Bayes' theorem
It follows directly from the definition of conditional probability.
The role of each term:
| Term | Name | Meaning |
|---|---|---|
| Prior | Belief about the parameter before observing data | |
| Likelihood | Plausibility of observing this data when the parameter is | |
| Posterior | Belief updated after observing data | |
| Evidence | Normalization constant |
The key shift in perspective: in frequentist statistics, is an unknown constant, while in Bayesian statistics, itself is a random variable. The notion of a "distribution over parameters" therefore makes sense, and inference is the process of tightening that distribution with data.
In practice, it is written as a proportionality that omits the normalization constant.
The problem: the posterior is generally intractable
has no closed form for most combinations of likelihood and prior. Major branches of modern Bayesian statistics—MCMC and variational inference—are devoted to approximating this integral. But for certain combinations, this integral is solved for free. That is conjugacy.
Conjugate priors
A prior family is conjugate to a likelihood if
The posterior remains in the same family as the prior, and updating ends with arithmetic on the parameters.
Representative example: Beta–Bernoulli
Suppose we estimate the probability that a coin comes up heads. If heads are observed in tosses, the likelihood is
Choose as the prior, so . Then
The right-hand side is exactly the kernel of . Without performing a single integral,
The update rule is "add the counts." can be read as the number of successes observed so far plus the prior success count, while is the failure count. This is why are called pseudo-counts. Starting from (= Uniform) makes an "observer with no bias," while starting from gives a "strong prior belief that the coin is fair."
Why those combinations fit — the exponential family
This is no coincidence. If the likelihood belongs to the exponential family,
a conjugate prior always exists, and updating reduces to accumulating the sufficient statistic . Frequently used conjugate pairs include:
| Likelihood | Conjugate prior | Posterior update |
|---|---|---|
| Bernoulli / binomial | Beta | Add success and failure counts |
| Poisson | Gamma | Add event counts and observation counts |
| Normal (known variance) | Normal | Precision-weighted mean |
| Normal (unknown mean and variance) | Normal-Inverse-Gamma | Update four parameters |
| Categorical / multinomial | Dirichlet | Add counts for each category |
The third row is important: the Gaussian is conjugate to itself for its mean. From the perspective of conjugacy, Gaussian and Beta distributions play the same role on their respective stages (continuous location parameters versus probability parameters).
Posterior predictive distribution
The distribution of the next observation is obtained by integrating out parameter uncertainty.
For Beta–Bernoulli, the Beta function identity gives this integral in closed form:
This formula contains Laplace's rule of succession as a special case (with , it becomes ). Smoothing that "does not conclude the probability is zero even after zero observations" emerges automatically.
Sequential updating — the online nature of Bayesian inference
Thanks to conjugacy, even when data arrives as a stream, only a few parameters are needed as state.
- The final posterior is identical whether all data is inserted at once or one item at a time (exchangeability).
- This structure enables Thompson sampling in multi-armed bandits (see the Beta distribution page) and real-time monitoring of A/B tests.
Limitations of conjugacy
- Restricted expressiveness: real prior knowledge may not have a Beta shape. Conjugacy is a computational convenience, not an epistemological justification.
- In complex models (hierarchical models and neural networks), the conjugate structure breaks and MCMC or variational inference becomes necessary. Even within those algorithms, however, conjugate blocks remain useful performance levers (for example, full conditional distributions in Gibbs sampling).
What to remember from this page
- Bayesian inference = prior × likelihood ∝ posterior. Its essence is the shift in perspective that promotes the parameter to a random variable.
- Conjugacy = the property that the posterior remains in the prior's family. Updating reduces to arithmetic on sufficient statistics.
- Beta–Bernoulli is the archetypal conjugate pair: , and its parameters are pseudo-counts.
- The posterior predictive mean has automatic smoothing built in.
Next step
The background theory is complete. We now confront the three distributions directly.