Galton Board Simulator
Equations in this simulation
| n | Rows of pegs, or number of dice, n | each row is one yes-or-no trial: bounce right or left | |
|---|---|---|---|
| p | Chance of bouncing right p | the same at every peg, and each bounce independent of the last | |
| k | number of bounces to the right | which bin the ball lands in, counting from the left; C(n, k) is the number of paths that end there | |
| P(k) | binomial probability of landing in bin k | the middle bins have far more paths leading to them, which is why they fill up |
With the current values:
| μ | expected mean | the bin the pile centers on | |
|---|---|---|---|
| σ | expected standard deviation | grows only as the square root of n, so with more rows the pile is relatively narrower |
With the current values:
| f | normal curve with the same μ and σ | a good stand-in for the binomial when n p and n (1 − p) are both above about 5; with p near 0 or 1 and few rows the pile is lopsided and the curve misfits |
|---|
With the current values:
| O, E | observed and expected counts in each bin | bins expected to hold fewer than 5 balls are merged with their neighbors first | |
|---|---|---|---|
| χ² | chi-square statistic | how far the pile is from the binomial; the p-value is the chance of a gap at least this big by luck alone |
With the current values:
| n dice | Rows of pegs, or number of dice, n | one die is flat, two make a triangle, and by five or six the sum already looks like a bell: the central limit theorem |
|---|
With the current values:
| N | balls dropped so far | the sample mean wanders less and less from μ as N grows, as the chart of the mean over time shows |
|---|
With the current values:
How to use the Galton board simulator
- Balls drop from the top and bounce left or right at every peg. Each lands in a bin that counts how many times it went right, and the bars grow into a bell shape. The dashed line is the exact binomial distribution and the green curve the normal distribution with the same mean and standard deviation.
- Change the number of rows and the chance of bouncing right, which empties the board and starts again. With p far from 0.5 and few rows the pile is lopsided and the normal curve fits badly; with more rows it becomes a bell again. The chi-square test and its p-value say whether the pile is consistent with the binomial, and the charts over time show the sample mean settling down as more balls fall.
- Switch to the sum of dice: one die gives a flat distribution and two a triangle, but by five or six dice the sum is already bell-shaped, the central limit theorem. Roll real dice with the Dice Roller, and work out a mean and standard deviation from your own data with the Standard Deviation Calculator.
Frequently asked questions
What is a Galton board?
A board of pegs in staggered rows, invented by Francis Galton in the 1870s and also called a bean machine or quincunx. Each ball makes a left-or-right choice at every row, so the bin it lands in counts its rights, and the pile at the bottom follows the binomial distribution. With many rows it looks like the normal curve.
Why do the balls pile up in the middle?
There are many more paths to the middle bins than to the edges. With 12 rows only one path, all lefts, leads to the leftmost bin, but 924 different paths lead to the middle one. With equal chances each path is equally likely, so the middle bin gets 924 times as many balls as an end bin: C(n, k) ways to reach bin k.
What is the central limit theorem?
The sum (or average) of many independent random amounts tends toward a normal distribution, whatever the distribution of each one, as long as it has a finite spread. Each peg is a tiny random step of plus or minus one, and the dice are flat on their own, yet both add up to a bell curve. It is why the normal distribution turns up so often in measurements.
How many balls do I need before the pile looks right?
The random scatter in each bin is about the square root of its count, so a bin expecting 100 balls is typically off by 10 (10%), and one expecting 10,000 by 100 (1%). A few hundred balls show the shape; thousands are needed for it to look smooth. The chi-square p-value should land anywhere between 0 and 1 for a fair board, below 0.05 about one time in twenty.
It says WebGL is turned off.
The 3D view needs WebGL, which every current browser has. It can be switched off by hardware acceleration being disabled in the browser settings, or by a very old graphics driver. Turn hardware acceleration on, or try another browser.
Is anything uploaded?
No. The simulation is drawn by your own browser with WebGL; nothing is sent anywhere, and it keeps working offline once the page has loaded.