Plinko is a binomial distribution: Pascal's triangle and a JavaScript simulation
A Plinko board looks chaotic. A ball drops in at the top, bounces off one peg per row, and lands in one of the slots at the bottom. But the slot it lands in follows one of the best-known distributions in probability, and Pascal's triangle is enough to derive it. This post derives the math, then checks it with a short JavaScript simulation. Every code block below is part of one script: paste them…
The Plinko board is a chaotic-looking device that, mathematically, follows a binomial distribution. It starts with a ball dropped at the top, bouncing off pegs row by row until it lands in one of the slots at the bottom. Interestingly, this final slot's position corresponds to one of the most renowned probability distributions: the binomial distribution. Pascal's triangle, a well-known mathematical structure, plays a crucial role in deriving this distribution.
A digital Plinko board with n rows of pegs results in n decisions for the ball, each being either left or right with equal probability (½). The ball's final slot is determined by the number of times it went right. With zero right bounces, the ball lands in the leftmost slot, and with n right bounces, it lands in the rightmost slot. Thus, an n-row board has n + 1 slots, numbered from 0 to n. This concept is the classic off-by-one error, where 8 rows translate to 9 slots.
In this context, K represents the slot number, and K ~ Binomial(n, ½) signifies that K follows a binomial distribution with parameters n and ½. The probability of the ball landing in a specific slot is given by P(K = k) = C(n, k) / 2^n, where C(n, k) represents the number of different paths with exactly k right bounces, and each of the 2^n paths is equally likely.
A physical board, such as the Galton board, approximates this model but has momentum and imperfect pegs, making it slightly different from the digital board. However, the digital board can accurately simulate the process using fair coin flips.
Pascal's triangle is instrumental in determining the path count for each slot. The nth row of Pascal's triangle lists the combinations C(n, 0) to C(n, n), where each entry is the sum of the two entries above it. This recursive rule mirrors the ball's movement on the board, where the number of ways to reach a peg equals the sum of the ways to reach the peg directly above it from the left and the right.
To generate one row of Pascal's triangle, you can start with 1 and iteratively calculate each subsequent entry using the formula C(n, k + 1) = C(n, k) · (n - k) / (k + 1).
Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.