Overview

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.
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.
Prior and posterior probability distributions of 𝑝, the proportion of tea drinkers.
Comparison between the posterior distributions of 𝑝 under different prior distributions.
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 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 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.
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.

FAQ

What is a conjugate prior in Bayesian inference?A conjugate prior is a prior distribution that makes the posterior stay in the same family of distributions after observing data. This gives a closed-form Bayesian update, so the posterior can be computed directly from the prior’s hyperparameters and the observed data.
Why are conjugate priors useful?They avoid heavy computation, numerical approximation, and difficult integration. Instead of estimating the posterior with iterative methods, you can update the prior instantly using a known formula.
Why does the chapter move from discrete hypotheses to continuous ones?Because the earlier discrete model only considered a finite number of possible values for the unknown proportion. A continuous model lets us represent uncertainty over every value between 0 and 1, giving a more precise Bayesian description.
What is the difference between a probability mass function and a probability density function?A PMF gives exact probabilities for discrete outcomes, while a PDF gives relative likelihoods in a continuous setting. In a continuous model, probabilities come from areas under the curve, not from the height at a single point.
Why is the probability of one exact continuous value effectively zero?Because a single value has no area under the curve. In a continuous distribution, only intervals have nonzero probability, so the probability of exactly one point is essentially zero.
How does the beta-binomial model update the prior for a proportion?If the prior is Beta(α, β) and the data contain k successes out of n trials, the posterior is Beta(α + k, β + n - k). This is why the beta distribution is conjugate to the binomial likelihood.
What do the beta distribution hyperparameters α and β mean?They act like pseudo-counts: α corresponds to prior successes and β corresponds to prior failures. Larger values mean stronger prior confidence, while smaller values mean a weaker or more flexible prior.
How do we use the CDF to answer probability questions about the posterior?The CDF gives the probability that a variable is below a threshold. To find the probability that it exceeds a value, subtract the CDF from 1; to find the probability in a range, subtract the CDF at the lower bound from the CDF at the upper bound.
Why is a normal prior conjugate for Bayesian linear regression?Because when the prior on the slope is normal and the noise is also normal, the posterior remains normal. This preserves the same distribution family and allows closed-form formulas for the updated mean and variance.
What is the posterior predictive distribution in Bayesian linear regression?It is the distribution of future outputs after combining uncertainty about the model parameter with observation noise. Instead of one fixed prediction, you get a full probability distribution for each new input, along with credible intervals.

pro $24.99 per month

  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose one free eBook per month to keep
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime

lite $19.99 per month

  • access to all Manning books, including MEAPs!

team

5, 10 or 20 seats+ for your team - learn more


Close
choose your plan

team

monthly
annual
$49.99
$499.99
only $41.67 per month
  • five seats for your team
  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose another free product every time you renew
  • choose twelve free products per year
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime
  • renews annually, pause or cancel renewal anytime
  • Grokking Bayes Grokking Bayes ebook for free
Close
choose your plan

team

monthly
annual
$49.99
$499.99
only $41.67 per month
  • five seats for your team
  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose another free product every time you renew
  • choose twelve free products per year
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime
  • renews annually, pause or cancel renewal anytime
  • Grokking Bayes Grokking Bayes ebook for free