A Galton board: watching the bell curve emerge in your browser

I studied systems engineering with a specialization in operations research. That choice was deliberate: you could already learn to program on your own, from books and a compiler. What really stayed with me were the mathematical ideas behind systems: experiments, probability, data mining, and the early concepts we used to call artificial intelligence. Today I’d call myself more of a software engineer, but those roots never left.

And one idea stuck with me more than any other: the Gaussian. The normal distribution, the way real-world data piles up around a center, the logic of sampling. I still think the bell curve is one of the most beautiful ideas in mathematics. It’s the same thread that later led me to build Terra ML, the fuzzy satellite-image classifier from my 2008 thesis: support vector machines, genetic algorithms, the whole statistical-learning family. Same fascination, different decade.

So when a Galton board drifted across my Twitter feed a while ago, it hit a nerve. I first looked for a physical one online. They run from about $30 to $100, but I quickly realized it would be more interesting to build one digitally, reproducing the physics in the browser.

One important detail up front: this is not a naive physics simulation. A purely physical model doesn’t naturally produce the clean bell curve people expect, so I used a hybrid model that keeps the visual physics while enforcing the statistical process behind the Galton board. More on that below.

Here it is. Pull the lever, hit Rain, and watch a few hundred steel beads form a bell curve in real time.

Board not showing? Open it full screen.

The dashed blue curve is the theoretical normal. The blue numbers under each bin are the expected percentages; the green numbers are the live count. The readout tracks the empirical mean and standard deviation as the beads settle. Now let me tell you what you’re actually looking at.

What you’re looking at

The machine is a quincunx, Sir Francis Galton’s “bean machine,” which he described in 1894. Every bead that falls makes a sequence of independent left-or-right choices, one at each row of pins, and lands in a bin at the bottom. No one is sorting the beads. The piles that form are a histogram, drawn in real time by physics. The shape that emerges, run after run, is the normal distribution.

What the bell curve demonstrates

This is the Central Limit Theorem made physical. Each bead’s final position is a sum of many small, independent ±½ steps. Sum enough independent random choices and their total doesn’t stay uniform or chaotic; it converges to a bell. Nobody draws the curve. It’s the inevitable shape of adding up chances.

That single fact is why the normal distribution is everywhere in the real world. Heights, measurement errors, sensor noise, the average of almost anything: whenever a quantity is the sum of many small, independent effects, it ends up approximately normal. The Galton board isn’t simulating that principle; it’s a tiny physical proof of it. It is order emerging from randomness.

What σ really measures

The width of that bell has a name: σ, the standard deviation. The board makes it tangible. Watch the readout and you’ll see the empirical σ settle near the theoretical value of √(rows)/2, which is √(12)/2 ≈ 1.73 for the 12-row board. σ isn’t an abstract symbol here; it’s literally how wide the pile spreads.

And it spreads in a very specific way. About 68% of the beads land within one σ of the center, about 95% within two σ, and about 99.7% within three. That’s the famous 68-95-99.7 rule. You can watch the bins fill in roughly that proportion every time.

Why care? Because σ is the natural ruler for “how unusual is this?” It’s the unit behind z-scores, behind control charts on a factory floor, behind “six sigma” quality, behind confidence intervals and A/B tests. σ is what turns a vague sense of spread into a number you can actually reason and make decisions with.

What the probabilities demonstrate

Look under the bins at the blue percentages. Each one is the expected probability of landing in that bin, and it comes from a clean formula: the binomial, C(n,k) / 2ⁿ. Those coefficients C(n,k) aren’t arbitrary; they’re Pascal’s triangle, which the board prints right on top of the pins. Each number counts the distinct paths a bead can take to reach that point. The column on the right, the powers of 2, is the total number of possible paths: 2ⁿ. Probability here is just counting paths and dividing.

Now watch the green live counts chase the blue expected percentages as the beads pile up. That chase is the law of large numbers in motion: a short run is lumpy and a little unfair, but the longer it runs, the closer reality hugs the theory. The honest caveat, and it matters, is that any single run is pure chance. The lawful, predictable part is the distribution, not the individual bead.

Why it’s not just a toy

Galton didn’t build the quincunx for fun. Studying how those piles formed led him straight to correlation, regression, and the phrase he coined, “regression to the mean,” which came out of his work on heredity. The humble bean machine sits at the origin of modern statistics.

The same intuitions are still working for a living today:

  • Teaching the CLT and regression to the mean: the fastest way to make either idea click.
  • Quality control and sampling: control charts, six-sigma, and process capability all speak in units of σ.
  • Knowing when “normal” is a safe assumption, and, just as importantly, when it isn’t (fat tails, dependence, skew).
  • The everyday lesson: randomness at the individual level, predictability in the aggregate. That’s the engine under insurance, polling, risk, and most of machine learning.

How I simulated it

Here’s the catch I flagged at the top, and that most demos quietly skip: pure physics does not make a bell curve. A real bead keeps its sideways momentum, drifts toward the walls, and the distribution comes out U-shaped. So this board uses a validated hybrid model: the collisions are genuinely simulated (the bouncing and stacking are real), but at each row crossing the bead gets a fresh 50/50 decision that resets its horizontal velocity. Thousands of those independent binary choices are exactly the binomial process the math describes. The physics you see is real; the statistics are honest.

It’s a single self-contained HTML file, fully offline and with zero runtime dependencies, built with Claude Code as a programming assistant and backed by a test suite that checks the empirical σ against the theoretical √(12/4) ≈ 1.73 and asserts zero escaped beads. Source and notes are on GitHub: github.com/ivanrlg/galton-board.

The supreme law of Unreason

Galton himself called this result “the supreme law of Unreason,” the eerie way that perfect order emerges from perfect chance. More than twenty years after an operations research classroom first introduced me to the normal distribution, here it is again, taking shape one random bounce at a time in a browser tab. Pull the lever a few times, change the number of rows, and watch the law assert itself. And if you’d rather hold the real thing, that $30 board is still waiting on Amazon.

Leave a Reply

Your email address will not be published. Required fields are marked *