Published
In this lesson
Wide tables, equations, and code scroll sideways. Swipe, or Tab to focus them and use the left and right arrow keys.
Galton board
You will learn: Count bounce paths and separate endpoint variation from histogram sampling noise.
Start with: Events and probability · Expectation and variance
A ball falls through rows of pegs, bouncing left or right at each row. Why do many balls collect near the middle? In the ideal model, there are many more left-right paths leading to a central bin than to an extreme bin.
Every bounce is independent and has the same probability p of going right. After n rows, the bin index K equals the number of right bounces, so K has a binomial distribution. This is an assumption about an ideal experiment. A physical board can have friction, unequal pegs, collisions between balls, and other departures from that model.
Follow one ball
Ball 1 makes 7 right bounces in 10 rows and enters bin 7. Its horizontal displacement in diagram units is 4. Each bounce is independent with the same p.
Filled left: exact binomial. Open right: observed fraction. Exact bin-index mean 5.000000, variance 2.500000. Total observed balls: 200.
Inspect all bin counts
| Bin | Exact probability | Observed count |
|---|---|---|
| 0 | 0.0009765625 | 0 |
| 1 | 0.009765625 | 4 |
| 2 | 0.04394531 | 8 |
| 3 | 0.1171875 | 22 |
| 4 | 0.2050781 | 43 |
| 5 | 0.2460938 | 55 |
| 6 | 0.2050781 | 34 |
| 7 | 0.1171875 | 23 |
| 8 | 0.04394531 | 10 |
| 9 | 0.009765625 | 1 |
| 10 | 0.0009765625 | 0 |
The path shows one selected ball, with its endpoint marked by a filled circle. Bins are numbered from zero at the far left to n at the far right. Each right bounce increases the bin index by one; a left bounce does not. Horizontal displacement in the drawing is 2K − n, a different coordinate from bin index K.
The histogram compares the exact endpoint probabilities with observed fractions. Increasing the number of balls retains all earlier paths. Increasing the rows extends each path, so you can inspect how the same early bounces lead to a later endpoint. The random seed chooses a reproducible collection of paths.
Count paths, not just bins
With n = 4 and p = 1/2 there are sixteen equally likely bounce sequences. The numbers reaching bins zero through four are 1,4,6,4,1. There is only one path to bin zero, LLLL, but six arrangements of two rights and two lefts reach bin two.
For general n, there are n choose k ways to place k right bounces among the rows. Each particular arrangement has probability p to the power k times (1 − p) to the power n − k. Multiplying gives P(K = k) = C(n,k)pᵏ(1 − p)ⁿ⁻ᵏ. Equal bin probabilities would count endpoints while ignoring their unequal numbers of paths.
The mean bin index is np and its variance is np(1 − p). At the default n = 10 and p = 1/2, the mean is five and variance is 2.5. The middle bin’s probability is C(10,5)/2¹⁰ = 252/1024, approximately 0.24609375. A sample of two hundred balls need not put exactly 49.21875 balls there: that fractional count is an expectation over repeated samples.
Change the bounce bias
Move p away from one half. The distribution shifts and can become visibly skewed. At p = 0 every ball ends in bin zero; at p = 1 every ball ends in bin n. Both cases have variance zero. With no rows there are no random bounces and all balls remain in bin zero, whatever p says.
Changing p in this experiment changes every bounce’s probability equally. It does not model a board whose left and right regions have different peg behavior. If the bounce probabilities vary by row but remain independent, the number of right bounces generally has a Poisson-binomial distribution. If bounces depend on earlier motion, even that independent-trial model can fail.
Make a prediction
Does doubling the number of balls change the exact width of the endpoint distribution?
Explore the answer
No. With the rows and p fixed, the distribution of one ball is unchanged. More balls make the histogram a more stable estimate of that distribution. Changing the number of rows changes the endpoint variance; changing the number of sampled balls changes estimation noise.
Where the bell shape enters
For many independent bounces with p away from the endpoints, the standardized bin index approaches a normal distribution as rows increase. The exact distribution remains discrete and bounded between zero and n. A bell-shaped approximation is less informative for very small n or strongly biased bounces, and it does not turn the probability of a single continuous normal value into a bin probability.
Reference and next step
Stanford CS109’s Galton board explanation identifies the bin index with the number of right bounces. Continue to the binomial distribution for interval probabilities and the central limit theorem for what normal approximation does and does not promise.