Overview

3 Conjugate priors for closed-form Bayesian updates: Skipping over heavy computations with clever math

In this chapter, the focus shifts from a discretized Bayesian view of uncertainty to a continuous one, where a quantity like the office tea-preference rate can take any value between 0 and 1. The key challenge is that continuous hypotheses cannot be handled by simply assigning probabilities to finitely many cases, so the chapter introduces probability densities, integrals, and the idea that only ranges of values have meaningful probability. This sets up a more accurate and flexible version of Bayesian updating while keeping the same core logic: start with a prior belief, combine it with data through a likelihood, and update to a posterior.

The main mathematical shortcut is the use of conjugate priors, distributions that produce posteriors from the same family and therefore avoid heavy computation. For proportions, the beta distribution pairs naturally with the binomial likelihood, making the prior update especially simple: the prior hyperparameters are incremented by observed successes and failures. The chapter uses the tea-versus-coffee example to show how a Beta(1,1) prior updated with 3 tea drinkers out of 5 becomes Beta(4,3), and explains how different beta priors encode different strengths of belief, from near-indifference to strong prior conviction.

The second major application is Bayesian linear regression, where a normal prior on the slope combines with a normal noise model to yield a normal posterior over the slope and a posterior predictive distribution over future house prices. This provides not just a best estimate but also uncertainty bounds, typically expressed as credible intervals, and it connects Bayesian priors to regularization by showing that stronger priors restrain overly large weights. The chapter ends by situating these ideas in a broader landscape of conjugate models, including the Dirichlet for multinomial outcomes and the Gamma for event rates, emphasizing that conjugate priors make Bayesian inference both practical and interpretable.

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 falls 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 produces a posterior in the same family as the prior after observing data. This makes Bayesian updating closed-form and avoids heavy numerical computation.
Why are conjugate priors useful?They let us compute posterior distributions exactly and efficiently. Instead of approximating integrals or doing expensive numerical updates, we can update parameters with simple formulas.
Why move from a discrete to a continuous model for the tea vs. coffee example?A continuous model lets us represent every value of the proportion p between 0 and 1, rather than only a small set of rounded hypotheses. This makes the model more precise.
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 continuous models, probabilities are obtained by integrating the PDF over an interval.
Why can’t we assign a nonzero probability to a single exact value in a continuous distribution?Because there are infinitely many possible values, the probability of any single exact value is effectively 0. Only ranges of values have meaningful probabilities, found as area under the PDF.
What is the beta–binomial conjugate pair?The beta distribution is the conjugate prior for the binomial likelihood. If the prior is Beta(α, β) and the data contain k successes in n trials, the posterior is Beta(α + k, β + n − k).
How do the beta hyperparameters α and β affect the prior?They control the shape and strength of belief. They can be interpreted as pseudo-counts of successes and failures, and larger values mean stronger prior confidence.
How does the chapter apply conjugate priors to Bayesian linear regression?It uses a normal prior for the slope m and a normal likelihood for noisy house-price data. Because normal distributions are conjugate here, the posterior for m is also normal with updated mean and variance.
What is a posterior predictive distribution?It is the distribution of a new unknown outcome obtained by combining the posterior over model parameters with the likelihood of new data. In the house-price example, it gives a predictive distribution for each future house price.
How is Bayesian linear regression related to regularization?Using a zero-centered prior on the weights acts like regularization. It discourages large weights, similar to L₂ regularization in standard linear regression, helping reduce overfitting.

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


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 ebook for free
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 ebook for free