Prior times likelihood: a posterior update

The question
Commit to a direction before the new distribution appears.
- 1 SeePredict, then add a coin result.
- 2 TryCompare the weight of two priors.
- 3 ProveBuild a normalized posterior.
- 4 ApplyCompute and interpret five updates.
Before you start · 3 quick checks on conditioning, independence and density
Two ideas before you start
2 ideasA distribution describes uncertainty about a parameter
Two selectable symmetric prior densities over the coin's heads probability.
The coin has one fixed, unknown heads probability. The prior curve describes uncertainty about that probability before these data are used.
Exact definition
Write \(p\) for the probability of heads, with \(0\lt p\lt1\). A prior density \(\pi(p)\) is nonnegative and integrates to one. Its area over an interval is the prior probability assigned to that interval. Its height at a single point is not a point probability.
This page uses beta densities with positive integer parameters \(a,b\):
\[\begin{aligned}\pi(p)&=\frac{p^{a-1}(1-p)^{b-1}}{B(a,b)},\\B(a,b)&=\int_0^1 u^{a-1}(1-u)^{b-1}\,du.\end{aligned}\]The symbol \(u\) is only the integration variable. A beta prior assigns no point mass to either endpoint. Changing the curve changes the assumed prior information, not the coin itself.
Hold the data fixed; vary the candidate
The likelihood of the ordered sequence heads, tails over candidate heads probabilities.
For the displayed sequence heads, tails, compare how well each candidate explains the same observations. The likelihood is a function of the candidate.
Exact definition
Conditional on the same fixed \(p\), tosses are independent Bernoulli trials: heads has probability \(p\), tails has probability \(1-p\). An observed ordered sequence \(D\) with \(h\) heads and \(t\) tails has likelihood
\[L(p)=P(D\mid p)=p^h(1-p)^t.\]The observed sequence stays fixed while \(p\) varies. Unlike a density over \(p\), a likelihood need not integrate to one. The lesson on maximum likelihood searches for its largest value. Here the goal is a whole distribution after observing data.
Refresher: beta integrals and what is being counted
No earlier lesson on beta distributions is needed. For positive integers, integration by parts gives \(B(a,b)=(a-1)!(b-1)!/(a+b-1)!\), with \(0!=1\). Dividing the beta integral with its first parameter increased by one by the original integral gives the mean \(a/(a+b)\). These identities are the calculation tools used below.
Conditional independence is essential. After averaging over an uncertain shared \(p\), tosses need not be independent. A long run of heads can change what you expect from the next toss without physically changing the coin.
The binomial count in the binomial and Poisson lesson includes a counting factor for all sequences with the same counts. For fixed sample size that factor does not depend on \(p\), so it cancels from a posterior. We use the ordered-sequence likelihood throughout. The event-probability version of the update is covered in Bayes' theorem and base rates.
Add one result
- Read the current distribution and the next observed result. Choose whether the posterior mean moves left, stays put or moves right.
- Your choice adds that result and reveals the multiplication. Continue to use the new posterior as the next prior.
- Start over clears the sequence, your choices and all revealed results.
These are supplied observations, not simulated tosses. The model assumes a fixed heads probability and independent tosses conditional on that probability. “Moves” refers to the mean, not a rigid translation of the curve.
Same observations, different priors
Both priors below have the same mean. Before comparing their updated values, decide what a difference in prior concentration will do. This comparison uses a new fixed batch of conditionally independent tosses.
| Prior | Posterior | Mean |
|---|
Use what you found above
- Choose the common parameter k of the symmetric Beta(k, k) prior. The observed batch stays fixed.
- Press Check setting for each goal. The next goal starts from the initial setting.
Why strength matters
Write \(s=a+b\) and \(m=a/s\). For a nonempty sample of size \(n=h+t\), the posterior mean is
\[\begin{aligned}E[p\mid D]&=\frac{a+h}{s+n}\\&=\frac{s}{s+n}m+\frac{n}{s+n}\frac{h}{n}.\end{aligned}\]It is a weighted average of the prior mean and the observed heads fraction. At a fixed prior mean, increasing \(s\) gives the prior more weight. Calling \(s\) a prior strength describes this formula; it does not assert that someone actually observed that many earlier tosses.
The prior and likelihood are assumptions, so compare reasonable choices when the sample is small. A concentrated prior can remain influential even when the data disagree with it. More data do not repair a changing coin probability or dependence that the model ignores. This page does not claim that every new observation reduces posterior variance.
Multiply, then normalize
Assume a Beta(a, b) prior with positive integer parameters and one fixed \(p\) in the open unit interval. Given \(p\), the tosses are independent, each with heads probability \(p\). Observe a particular ordered sequence with nonnegative integer counts \(h,t\) and \(n=h+t\ge1\).
Define the unnormalized product \(u(p)=\pi(p)L(p)\) and its area \(Z=\int_0^1u(p)\,dp\). Then
\[\begin{aligned}\pi(p\mid D)&=\frac{\pi(p)L(p)}{Z},\\p\mid D&\sim\operatorname{Beta}(a+h,b+t).\end{aligned}\]For these assumptions \(0\lt Z\lt1\), so normalization is possible. Here \(Z=P(D)\) is the prior predictive probability of this particular sequence, not the probability of a chosen parameter. The posterior is a Bayesian statement: it describes uncertainty about \(p\) given the chosen prior and the sampling model. Its interval probabilities are not model-free probabilities that a claim about the coin is true; a different prior gives a different posterior. The proof uses the definition of conditional density and the beta integral defined on Start.
Each option concerns the assumptions above and an interior candidate p. Nonempty data make its sequence likelihood strictly between zero and one.
Updating in batches gives the same result as updating one observation at a time: the likelihood factors multiply, and intermediate normalizing constants cancel. This requires the same prior, the same fixed parameter and each observation used once. Changing the order of the supplied tosses changes the intermediate curves but not the final posterior.
A posterior density can exceed one. Only its area over an interval is a probability, and its total area remains one. Also, multiplying the likelihood by a positive constant independent of p does not change the posterior, because that same constant multiplies Z. It does change the numerical normalizing constant, so a probability interpretation of Z requires the actual sampling likelihood.
Compute and interpret an update
Each problem has a hint and a worked solution. Enter a decimal; answers within the displayed tolerance of the unrounded value are accepted. Keep separate a parameter value, a density height and an area probability.
Further reading
- A. Gelman et al., Bayesian Data Analysis, chapter 2, “Single-parameter models.”