Conjugate families and posterior updating
Derive beta-binomial and gamma-Poisson updates while tracking normalization, units, and predictive dependence.
On this page
The question for today
What you’ll understand
- Recognize conjugacy by multiplying density kernels.
- Update beta and rate-parameterized gamma distributions correctly.
- Distinguish a posterior mean from a joint predictive probability.
Conjugacy means that a chosen prior family remains in the same family after a specified likelihood update. Its value is transparency: the algebra exposes exactly how information enters, supplies small examples with known answers, and helps test more complicated computation. Conjugacy does not establish that the prior is appropriate or that the sampling assumptions hold. We will update sufficient statistics, retain the resulting distribution rather than only its mean, and use that distribution to calculate predictions involving more than one future observation.
Beta and binomial kernels
For conditionally independent Bernoulli trials sharing success probability , a count has binomial likelihood proportional to . A beta prior with positive shape parameters has kernel on the unit interval. Multiplication adds exponents, giving another beta density. The binomial coefficient is constant in the parameter and cancels in posterior normalization, but it is required when calculating the marginal probability of observing a count.
The posterior mean combines the prior mean with the observed success fraction, with weights determined by and the number of trials. This motivates the phrase prior effective count, but literal invented observations are not required. In particular a beta density's exponents involve shape minus one, whereas its mean uses the shapes themselves. Confusing these conventions changes modes and boundary behavior. Both shapes must be strictly positive for the ordinary beta prior to be proper, even when one wants a very weak prior.
Exposure and gamma rates
For counts collected over known exposures , suppose are conditionally independent Poisson variables with means . A gamma prior in the shape-rate convention has kernel , with positive and . Observed counts add to the shape and exposure adds to the rate. Exposure need not be an integer. Its units are time if the unknown rate is events per unit time, so the posterior rate parameter has those time units as well.
The gamma scale convention instead uses the reciprocal of the rate. A numerical implementation that receives a scale where a rate was intended can reverse the prior's meaning. State the convention beside the formula and verify the mean and variance as a unit check. Sequential updating agrees with updating all conditionally independent batches together because multiplication is associative. This equivalence requires that the batches supply new information; updating twice with the same observations counts the same evidence twice and produces artificially concentrated uncertainty.
The distribution matters after updating
A future Bernoulli success probability equals the posterior mean, but the probability of two future successes involves the posterior second moment. Integrating a shared unknown parameter creates positive dependence between those future trials. Plugging the posterior mean into a binomial distribution discards that dependence and generally understates predictive dispersion. The resulting beta-binomial predictive law is still analytically tractable, so this is a useful setting for seeing exactly what uncertainty a point estimate omits.
Conjugate calculations also provide reference answers for software. Check posterior shape changes after all successes, all failures, and zero new trials; test whether predictive probabilities sum to one. A normal likelihood with known variance and a normal prior gives a related precision-addition rule, but unknown variance changes the conjugate family. Algebraically convenient assumptions should be checked against outliers, dependence, changing rates, and prior predictive behavior. When those assumptions fail, a nonconjugate model can be more useful than an exact answer to the wrong question.
Work it through
Update, then predict two successes
Start with Beta(2,3), observe four successes in six trials, and calculate the probability that the next two conditionally independent trials both succeed.
There are four successes and two failures, so the posterior shapes are 2+4=6 and 3+2=5. The normalized posterior is Beta(6,5), with mean 6/11.
For two future successes with the same unknown probability, integrate its square. A beta distribution has second moment alpha(alpha+1)/[(alpha+beta)(alpha+beta+1)], obtained by a ratio of beta integrals.
Substitute the posterior shapes: 6 times 7 divided by 11 times 12 equals 7/22. As a check, the posterior variance is 6 times 5 divided by 11 squared times 12, equal to 5/242; adding this to (6/11) squared also gives 7/22.
The joint success probability is 7/22, approximately 0.3182. Squaring the posterior mean gives approximately 0.2975 and omits uncertainty about the common rate.
The living notebook
Explore the model
Interactive lab · probability
Inspect the plug-in baseline
Pause and Reset, then set both controls to p=0.50 and n=2. Predict probability 0.25 for two successes. Reset and set p=0.60 and n=2; predict 0.36. The bars are fixed-probability binomials. Compare these squared probabilities with the second-moment calculation in the example; the instrument does not integrate a beta posterior.
- Mean · np
- 5
- Variance · np(1−p)
- 2.5
- Total probability
- 1
These are exact binomial probabilities for independent trials with one fixed success probability. Playback tours the distribution; it does not resample outcomes. Parameter changes pause playback and recompute the model at the current elapsed time. Reset restores both parameters and returns time to zero. Playback starts paused. Adjust either parameter, then choose Play or Step.
Look forA fixed-p count law is a baseline, while conjugate prediction averages such laws over the entire posterior.
Pause & reason
Check your understanding
Your turn
Try it yourself
A rate has Gamma(shape 3, rate 2) prior. Three conditionally independent counts, each over one unit of exposure, are 2, 0, and 3. Find the posterior distribution, mean, and variance.
Take a moment to make a prediction or work it out on paper. Open a hint when you need one.
Give me a hint
Keep the total count and total exposure in separate columns before adding either to a prior parameter.
Compare with the solution
Total count is five and total exposure is three. The posterior is Gamma(shape 8, rate 5). Its mean is 8/5 events per unit exposure and its variance is 8/25 in squared rate units. A zero count still contributes one unit of exposure, so discarding that observation would incorrectly change the denominator. This posterior assumes a constant underlying rate across all three exposures and the stated conditional independence.
Keep the idea
Take it with you
- Conjugacy follows from multiplying kernels and matching their support.
- Gamma rate and scale conventions must be explicit.
- Joint predictions require posterior moments beyond the mean.
Read further
Original sources and deeper explanations to follow at your own pace.
Optional progress, saved in this browser when available. Revisit any lesson at any time.
Lesson not marked complete.