Prior and posterior: Beta-Binomial
Lesson 12 of 15 · Stats.Micro
In Bayesian inference, a parameter (here, a coin's p) has a prior distribution expressing what we believe before the data. Observing data gives the posterior.
With a Beta(α, β) prior and coin flips, the update is simple: add heads to α and tails to β. A strong prior needs a lot of data to move; with enough data, the data dominate any reasonable prior. The simulated coin lands heads 65% of the time.
Recommendation systems use this to rate new items: a product with 2 reviews starts close to the prior and moves as reviews arrive.
With the uniform prior, flip at least 50 coins.
Choose the strong fair prior Beta(20, 20) and flip at least 50 coins.
Flip at least 300 coins until the posterior mean is within 0.05 of 0.65.
Why does the strong fair prior Beta(20, 20) resist the data at first?
- It already counts as 40 imaginary flips, so a few real flips barely move it
- Because the data are ignored in Bayesian inference
Watch a continuous prior distribution evolve in real time into a posterior distribution as coins are flipped.
The Beta distribution is conjugate to the Binomial likelihood. The posterior is another Beta distribution with updated parameters: α + y and β + n - y.
Prior success pseudocounts, Prior failure pseudocounts: (1, 1)
Do it in the browser: a real statistics tool, a short mission and instant feedback. No install.
Start this lesson — free