The engine behind every model in this course: posterior ∝ prior × likelihood. The posterior is a compromise between what you believed beforehand (the prior) and what the data say (the likelihood). More data lets the likelihood win; a stronger prior pulls harder. These figures let you feel that tug-of-war.
Turning "what we believe" plus "what we saw" into "what we now believe"
We want the probability of unknown parameters θ given the data — but our model tells us the reverse, the probability of the data given the parameters. Bayes' theorem inverts it:
The denominator p(data) does not depend on θ — it is just a constant that makes the posterior integrate to 1. So the shape of the answer comes entirely from the numerator, which is why the whole of Bayesian inference fits in one proportionality:
For the toy examples on this page the posterior has a tidy closed form. Real epidemic models have hundreds of parameters and no such formula, so the normalising integral p(data) is intractable. Instead of solving it we draw samples from the posterior using MCMC (in Stan). Each sample is one plausible parameter set — one possible version of the epidemic — and the cloud of samples is the posterior. Everything below is the conjugate, exactly-solvable shadow of that sampling machinery.
Estimating a reporting / ascertainment probability θ from "k of n" data
Suppose θ is a probability we want to learn — the chance a true case is reported, say, or a test comes back positive. We hold a prior belief about θ, then observe data: k successes in n trials. The likelihood of that data is Binomial, ∝ θk(1−θ)n−k. A Beta(a, b) prior, ∝ θa−1(1−θ)b−1, is the natural partner — multiply the two and the exponents simply add:
So updating is just bookkeeping: add the successes to a and the failures to b. The figure evaluates each Beta density on a fine grid of θ ∈ [0, 1] and normalises it numerically (the trapezoid rule) — no special functions needed. Watch how the posterior sits between prior and likelihood, and how it slides toward the data as n grows.
Press play to stream Bernoulli draws (each a "success" with true probability 0.7) and feed them in sequentially. The prior is fixed at whatever a, b you set above. Early on, the posterior barely moves from the prior; as the trials pile up the likelihood dominates and the posterior tightens around the true 0.7 — the data swamp the prior.
The "play" stream overrides the n and k sliders and uses the live prior a, b. Press reset stream to return to the manual sliders.
The posterior mean is a precision-weighted average of prior and data
Now θ is a continuous quantity — a mean we want to estimate (an average delay, a log-incidence level). We hold a prior N(μ0, σ0²) and observe n data points with sample mean x̄ and known observation noise σ. With a Normal prior and Normal likelihood the posterior is again Normal, and its mean is the two sources blended by their precisions (precision = 1/variance):
Read it as a weighted tug-of-war: whichever side is more precise (less variance, or — for the data — more observations) pulls the posterior toward itself. A confident prior (small σ0) holds firm; lots of data (large n) overwhelms it. And the posterior is always sharper than either input — precisions add, so it can only narrow.