Bayes’ Billiard Table
Thomas Bayes’ 1763 Essay analyzed an unknown position on a table from the observed left/right outcomes of later throws. This demo throws colored balls, counts the outcomes, and shows prior, likelihood, and posterior on a discrete grid, with a live histogram and the posterior mean.
posterior(p) ∝ prior(p) · p^6 (1−p)^0 · 95% interval [0.59, 0.99] · mean 0.875
Throw colored balls, then drag the white ball’s true position. Each throw is either to the left of the white ball (probability p) or to the right (probability 1 − p). The likelihood curve shows how well each possible p explains the counts; multiplying it by the prior gives the posterior. With more throws the posterior tightens around the truth, and the MAP estimate sits about 0.37 away from the real position here.
What you are seeing
A white ball sits at an unknown position p between 0 and 1. Each later ball lands left of it with probability p and right with probability 1 − p.
After k lefts and m rights, the likelihood of the data at position p is p^k (1 − p)^m. Multiplying by the prior gives a posterior proportional to prior × likelihood.
With a uniform prior the posterior is a Beta(k+1, m+1) distribution. The histogram, mean, and 95% interval all come from a discrete grid, so the numbers stay exact for the model shown.
Why it matters
Bayes’ reasoning became the foundation of Bayesian statistics. The same prior–likelihood–posterior pattern drives spam filters, medical testing, machine learning, and decision-making under uncertainty.
Complexity & details
On a grid of B positions, each update costs O(B). With k lefts and m rights the direct computation is O(B) per position, and drawing the histogram is O(B).
Frequently asked questions
Did Bayes write the modern formula?+
No. Bayes worked through a geometric tabletop example and did not use the compact posterior ∝ likelihood × prior notation. That shorthand and its general use came later, especially through Laplace.
Why use a discrete grid instead of a formula?+
A grid makes each number directly checkable and avoids hiding the assumptions inside closed-form algebra. Here it also reproduces the exact Beta(k+1, m+1) posterior, so correctness can be verified both ways.