Galton Board (2D)

Drop balls through rows of pegs and watch a bell curve appear: the binomial law, the central limit theorem and chi-square tests.

Presets

Playback

Board

Flow

Layers

Model check

The science

What you are looking at

Balls fall through a triangle of pegs. At every peg the ball goes left or right. After n rows its final bin k is the number of times it went right. Sir Francis Galton built this board in the 1870s to show how many small independent random pushes add up to a bell curve.

The binomial law

If each peg sends a ball right with probability p, the bin number K is the sum of n independent yes/no steps, so P(K = k) = C(n, k) p^k (1 - p)^(n - k). The mean is n p and the variance is n p (1 - p). The yellow bars on the board are this exact law, computed here by the Pascal-triangle recursion and not from the formula; the check compares both.

Why it becomes a bell curve

The central limit theorem says that the sum of many independent steps is close to a normal distribution with the same mean and variance, exp(-(k - np)^2 / (2 n p q)) / sqrt(2 pi n p q) (de Moivre and Laplace). How close is bounded by the Berry-Esseen theorem: the largest gap between the two cumulative distributions is at most 0.56 (p^2 + q^2) / sqrt(n p q). A fair board with 20 rows is already very close; a board with p = 0.1 needs many more rows because the binomial is skewed (skewness (1 - 2p) / sqrt(npq)).

Is the sample like the theory? The chi-square test

With N balls, bin k should hold N P(K = k) of them. The statistic chi^2 = sum (O - E)^2 / E (bins merged until E is at least 5) follows a chi-square law with (bins - 1) degrees of freedom when the board really is binomial. A very small p-value would mean the sample is too unlike the theory. For the ideal board the p-value wanders between 0 and 1 as you drop more balls, which is exactly how a true model behaves.

Real balls versus ideal coin flips

In the physical mode nothing random is built in. Each ball is a disk falling under gravity and bouncing off fixed pegs with restitution e; the only source of variety is the tiny random launch position, which collisions amplify. Real boards are close to p = 1/2 when they are level; a small sideways tilt shifts the whole distribution. Ball-to-ball contact and friction are neglected, and the tabulated chi-square compares the real board with the fair-coin law (p = the p slider).

Numerical checks on this page

  • The Pascal recursion for the distribution is compared with the closed form (sum, mean, variance and every bin).
  • A 40,000-ball Monte Carlo of the ideal walk (own random generator) must give a mean within four standard errors of n p and variance within 3 % of n p q.
  • The distance between the binomial and its normal approximation must be below the Berry-Esseen bound.
  • The physical integrator is checked by free fall through 0.5 m: speed sqrt(2 g h) and time sqrt(2 h / g).

What is simplified

Peg spacing, ball and peg sizes and gravity are fixed to a plausible small board. The ideal mode animates each ball along a prepared path with a smooth fall between rows; it does not simulate bouncing. The physical mode uses rigid disks, a fixed time step of 1/400 s and no friction or spin, so it is a teaching model and not a precise replica of a real board.

What to try

  • Fair board, 12 rows: drop 1000 balls and compare the bars with the yellow ticks and the green curve.
  • Set p = 0.1 with 20 rows: the curve is lopsided and the normal approximation is poor.
  • Switch to physical balls and then add a tilt of 1 degree.
  • Use 4 rows and 20 rows and watch the Berry-Esseen graph.
Histogram vs exact binomial and normal curve
Running sample mean
Convergence to the normal curve (CLT)
Cumulative distribution: observed vs exact