Three people start with different beliefs about one coin, then watch the same flips. Watch their beliefs move together.
Evidence wins over first guesses
Three people's beliefs about one coin with chance 0.7, updated by the same flips (seed 7200).
Three people, one coin. Open-minded starts flat; doubtful expects tails, mean 0.2; keen expects heads, mean 0.8.
Predict first. After 1000 flips, how far apart will their best guesses be?
Describe this picture
One panel with three belief curves over the coin’s chance of heads , from 0 to 1, one for each of three people, told apart by colour and by line style (solid, dashed, dotted) and named in a key above them. A faint dotted line marks the true chance, 0.7. Under the plot, on the same scale, three bars mark each person’s 95 % credible interval, with a dot at the mean. The open-minded person starts flat, ; the doubtful one starts with a curve centred low, , mean 0.2; the keen one starts centred high, , mean 0.8. Before the clip a question asks how far apart their best guesses will be after 1000 flips: still far apart, about a point apart, or exactly the same. A tap picks one and starts the clip. In the clip 200 seeded flips of a coin with true (seed 7200) land slowly, and the three curves, starting far apart, narrow and pour together; the vertical scale grows as they sharpen. The picture holds at 200 flips, then 800 more land quickly. After 1000 flips, 703 of them heads, the means are 0.7026, 0.6980 and 0.7040. Readouts give the flips, the heads, and each person’s posterior mean and 95 % credible interval. After the clip a slider, “Flips seen”, replays the same run from 0 to 1000 flips in steps of 10.
Three priors, the same flips
Before the clip you guessed. After 1000 flips the three people agree to within about a point: their means differ by less than 0.01. In the clip’s run, 703 heads in 1000 flips, they are 0.7026, 0.6980 and 0.7040. At the start they were far apart, one expecting tails, one heads, one with no view at all. The evidence did not erase their priors; it outweighed them.
Each person updates by the rule of Bayesian updating: posterior is prior times likelihood, rescaled. The only difference between them is where they started.
A prior as imaginary flips
A prior has the shape . Multiply by the likelihood of heads in flips, , and the powers add:
The posterior is again a beta curve: the data simply add to the first number and to the second. So the prior acts as if you had already seen heads and tails. Its strength, , is how many imaginary flips it is worth. The doubtful prior is worth 10 flips with 2 heads; the open-minded is worth only 2.
The posterior mean, for the new numbers, is a weighted average of the prior’s mean and the share of heads in the data:
The weight on the prior is its strength over the total. After real flips, prior and data count equally. After many more, is small and every reasonable prior gives nearly the same answer.
The best single guess
The posterior is a whole curve. If you must report one number, which?
Suppose a wrong guess costs the square of its error. The expected cost is
the same split as bias and variance in Estimators: bias and variance. It is smallest when is the posterior mean. If instead the cost is the size of the error, the best guess is the posterior median. The peak of the curve is the most believable single value, but under neither cost is it the best report.
Credible intervals
To report a range, cut off 2.5 % of the posterior’s area in each tail. What is left is a 95 % credible interval :
Its meaning is direct: given this prior and these data, the belief that lies in the interval is 0.95. For 7 heads in 10 flips from the flat prior, the posterior is and the interval runs from to .
Credible or confidence
The two kinds of interval answer different questions, and they are easy to confuse.
Watch out
A credible interval is a statement about , given the data and a prior: the posterior puts 95 % of its belief inside it. A confidence interval, as in Confidence intervals, is a statement about a recipe: used on sample after sample, it catches the fixed true value 95 % of the time. It says nothing about the chance that this one interval is right, and it needs no prior.
The numbers can still be close. For 7 heads in 10, the flat-prior credible interval is to ; the Wilson confidence interval is to . The plain interval gives to , which leans too far towards 1 for so few flips.
Worked example
1. Seven heads in ten. The open-minded posterior is : mean , peak , median about , 95 % credible interval to . Its variance is . Guessing the peak, 0.7, costs in expected squared error; guessing the mean costs only .
The doubtful person ends at , mean : exactly halfway between their prior mean, 0.2, and the data’s share, 0.7, because their prior is worth 10 flips and the data are 10 flips (). The keen person ends at , mean .
2. More flips, the same share of heads.
| Flips | Heads | Open-minded | Doubtful | Keen | Largest gap |
|---|---|---|---|---|---|
| 10 | 7 | 0.667 | 0.450 | 0.750 | 0.300 |
| 100 | 70 | 0.696 | 0.655 | 0.709 | about 0.05 |
| 1000 | 700 | 0.700 | 0.695 | 0.701 | 0.006 |
Once the flips far outnumber the priors’ strengths, ten times the data shrinks the gap about tenfold, because the weight on each prior falls like .
3. A weak prior. Start from and see 3 heads in 4 flips: the posterior is , with mean . The flat prior barely affects any answer once a few dozen flips are in.
Try it yourself. After flips, what fraction of the posterior mean comes from the prior? Half. Which cost makes the median the best guess? The size of the error.
Where you’ll meet this
Experiments with a history. A company that has run many similar A/B tests can start each new test from a prior built on the old ones. Small new tests then give sensible answers instead of wild ones.
Medicine with few patients. Trials for rare diseases, where every patient counts, often use priors from earlier studies, stated openly so that others can rerun the analysis with their own.
Rates of rare events. Spam rates, fault rates and click rates are tracked with beta posteriors that update as counts arrive.
In signal processing · the Kalman gain
The weight on the prior has a twin in signal processing. The Kalman filter blends its prediction with each new measurement using a gain set by their uncertainties, as RLS and the Kalman filter shows in the signal processing course.
Where this leads · shrinkage
The posterior mean pulls the data’s share towards the prior’s mean: a shrinkage estimator, like the factor of Estimators: bias and variance. Ridge regression, in The pseudo-inverse of the linear algebra course, is the same idea with a bell-shaped prior.
Reference card
| Quantity | Formula | Notes |
|---|---|---|
| Beta prior | , strength | like heads and tails seen before |
| Update | the data add to the two numbers | |
| Posterior mean | , | prior and data blended |
| Peak | flat prior: | |
| Best guess | squared error: mean; size of error: median | |
| Credible interval | a statement about , given a prior | |
| Confidence interval | the recipe catches the truth in 95 % of samples | a statement about the recipe |