Bayesian Updating
Prior → Likelihood → Posterior — the Beta-Binomial conjugate model
What It Demonstrates
Bayes' theorem tells us how to update beliefs when new evidence arrives. For a coin with unknown bias p, the Beta distribution Beta(α, β) is a natural prior — it lives on [0, 1] and encodes pseudocounts of (H, T) outcomes. After observing k heads in n flips, the conjugate update is exact:
Prior Beta(α, β) + k heads, n−k tails → Posterior Beta(α+k, β+n−k)
No integration, no approximation — only two numbers change. This conjugacy is why the Beta-Binomial model is the textbook workhorse for proportion inference.
The simulation shows three curves: prior (your initial belief), posterior (updated belief after flips), and a vertical marker for the true p you set.
How to Use
- Set Prior α, β: α = β = 1 is a flat (Uniform) prior. α = β = 0.5 is Jeffreys'. Large α favouring heads (α ≫ β) is an optimistic prior.
- Set True p: the coin's actual bias. The Bayesian does not see this directly — they only observe flip outcomes.
- Click Flip 1 / 5 / 20 / 100 or toggle Auto-flip to accumulate evidence.
- Watch how the posterior narrows and centres on the true p as n grows.
- Hit Reset to clear flips and start over (prior parameters remain).
Did You Know?
Bayesian updating is at the heart of spam filters, medical testing (PPV vs NPV), GPS receivers, and modern machine learning. The 95% credible interval shown here has a clean interpretation: "There is a 95% probability (given the data and prior) that p lies within this range" — unlike a frequentist confidence interval, which keeps the parameter fixed and varies hypothetical samples.