3 Conjugate priors for closed-form Bayesian updates: Skipping over heavy computations with clever math
In this chapter, the reader is introduced to a more general Bayesian approach that works on continuous parameter spaces instead of a small set of rounded hypotheses. The key motivation is to avoid the loss of precision and numerical strain that come from discretizing unknown quantities like a tea-preference proportion, while still using Bayes’ theorem to update beliefs from data. The chapter explains the shift from probability mass in discrete settings to probability density in continuous ones, emphasizing that individual values no longer carry literal probability; instead, probabilities come from areas under a curve over ranges of values.
The main mathematical idea is conjugate priors: special prior distributions that preserve the distribution family after observing data, allowing exact, closed-form posterior updates. The chapter develops this idea first for the beta–binomial model, where a beta prior over a proportion updates neatly by adding observed successes and failures to the hyperparameters. It also shows how different beta choices encode different beliefs, from flat indifference to stronger prior confidence, and how the cumulative distribution function lets us compute probabilities over intervals or thresholds. The chapter then generalizes the same logic to another common conjugate pair, using a normal prior and normal likelihood for Bayesian linear regression, where the slope of a relationship is treated probabilistically rather than as a single best-fit value.
In the regression example, the chapter shows how a prior over the slope and a Gaussian noise model yield a normal posterior whose mean and variance can be updated directly from the data. This produces not only an updated estimate of the slope, but also posterior predictive distributions for future values, complete with credible intervals that quantify uncertainty. The discussion closes by highlighting how Bayesian priors can act like regularization, helping prevent overfitting when data are sparse or noisy, and by pointing to broader extensions such as multinomial/Dirichlet models, gamma priors for event rates, multivariate regression, and more advanced Bayesian methods. Overall, the chapter’s message is that conjugate priors make Bayesian updating practical, elegant, and computationally efficient.
The procedure of deriving the posterior distribution under a Bayesian model: the prior is multiplied with the likelihood to produce the unnormalized posterior probabilities. These values are then normalized so that they sum to 1 to yield the posterior probabilities.
Prior and posterior probability distributions of 𝑝, the proportion of tea drinkers.
Comparison between the posterior distributions of 𝑝 under different prior distributions.
The prior distribution of the slope 𝑚 in the linear regression model, which gives the highest probability to the value 100 but there’s a high level of uncertainty in this value, quantified by the large spread of the distribution.
The prior and posterior distributions of the slope 𝑚. The posterior distribution sharply peaks around the true value 𝑚 = 200 to reflect the insight from the observed data.
The posterior predictive distribution of individual datapoints in the test set, illustrated by the predictive mean and 95% credible intervals. Most datapoints in the training set fall within the credible intervals.
Summary
- Conjugate priors are special priors that yield posteriors in the same family of distributions, enabling closed-form Bayesian updates.
- By switching from discrete to continuous priors (such as the beta distribution for proportions), we avoid the need to round or bin parameter values.
- A beta prior combined with a binomial likelihood yields a beta posterior—this is known as the beta–binomial conjugate pair.
- In the continuous setting, probability densities replace probability masses, and integrals replace sums to compute probabilities.
- The beta distribution is flexible and can represent a wide range of prior beliefs using its two hyperparameters.
- Conjugate priors simplify the math of Bayesian inference by eliminating the need for complex integration in the posterior normalization.
- The normal–normal conjugate pair models real-valued parameters like the slope in linear regression, yielding a normal posterior.
- Bayesian linear regression yields not just a point estimate but a distribution over the slope, capturing uncertainty.
- The posterior predictive distribution for new datapoints includes both the uncertainty in the parameters and in the observation noise.
- Bayesian priors play a similar role to regularization in the traditional linear regression model, controlling model complexity especially in low-data settings.
- Gaussian processes can be seen as a generalization of Bayesian linear regression to infinite-degree polynomials.
Grokking Bayes ebook for free