advanced34 min studyLesson 262 in Mathematics

Conjugate families and posterior updating

Derive beta-binomial and gamma-Poisson updates while tracking normalization, units, and predictive dependence.

On this page

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 nn conditionally independent Bernoulli trials sharing success probability θ\theta, a count yy has binomial likelihood proportional to θy(1−θ)n−y\theta^y(1-\theta)^{n-y}. A beta prior with positive shape parameters has kernel θα−1(1−θ)β−1\theta^{\alpha-1}(1-\theta)^{\beta-1} 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 α+β\alpha+\beta 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.

θ∼Beta⁡(α,β),Y∣θ∼Binomial⁡(n,θ)⟹θ∣Y=y∼Beta⁡(α+y,β+n−y)\theta\sim\operatorname{Beta}(\alpha,\beta),\quad Y\mid\theta\sim\operatorname{Binomial}(n,\theta)\quad\Longrightarrow\quad\theta\mid Y=y\sim\operatorname{Beta}(\alpha+y,\beta+n-y)
The update assumes a common probability and conditional independence, with positive prior shapes.↔ Scroll wide equations horizontally.

Exposure and gamma rates

For counts collected over known exposures tit_i, suppose Yi∣λY_i\mid\lambda are conditionally independent Poisson variables with means tiλt_i\lambda. A gamma prior in the shape-rate convention has kernel λa−1e−bλ\lambda^{a-1}e^{-b\lambda}, with positive aa and bb. 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.

λ∣y∼Gamma⁡ ⁣(a+∑iyi, b+∑iti),E[λ∣y]=a+∑iyib+∑iti\lambda\mid y\sim\operatorname{Gamma}\!\left(a+\sum_i y_i,\ b+\sum_i t_i\right),\qquad \mathbb E[\lambda\mid y]=\frac{a+\sum_i y_i}{b+\sum_i t_i}
Gamma uses shape and rate here. The variance is posterior shape divided by squared posterior rate.↔ Scroll wide equations horizontally.

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.

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.

  1. 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.

  2. 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.

  3. 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.

E[θ2∣y]=Var⁡(θ∣y)+E[θ∣y]2\mathbb E[\theta^2\mid y]=\operatorname{Var}(\theta\mid y)+\mathbb E[\theta\mid y]^2
Positive posterior variance increases this joint probability above a plug-in calculation.↔ Scroll wide equations horizontally.
The result

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.

Explore the model

Interactive lab

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.

Inspect the plug-in baselineThese are exact binomial probabilities for independent trials with one fixed success probability. Playback tours the distribution; it does not resample outcomes. Current readings: Mean · np: 5; Variance · np(1−p): 2.5; Total probability: 1. All parameters are adjustable with the labeled controls below.03581000.070.150.220.3Successes kP(X = k)k = 0 · P = 9.77e-4
Exact probabilityHighlighted outcomeMean np
Mean · np
5
Variance · np(1−p)
2.5
Total probability
1
t = 0 s

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.

Check your understanding

In a shape-rate gamma-Poisson update, what is added to the prior rate?

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.

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.