The board
A ball drops through a triangular array of pegs. At the first peg it goes left or right with probability $\tfrac12$ each. At every peg after that it repeats the direction it took last with probability $p$ and reverses with probability $q = 1-p$. At $p = \tfrac12$ the bounces are independent and the bins are binomial. At $p = 1$ the ball never turns and lands in an extreme bin. At $p = 0$ it alternates.
We count bounces rather than rows. After $N$ bounces the ball is in one of $N+1$ bins, and bin $k$ means $k$ bounces to the right. Kagey's row $n$ is our $N = n-1$, so his ten-bar histograms are $N = 9$. He tabulates numerators rather than probabilities: for $p = \alpha/(\alpha+\beta)$ in lowest terms the entry is
$$n_N(k) = 2(\alpha+\beta)^{N-1}P_N(k), \qquad N \ge 1,$$left unreduced, where $P_N(k)$ is the probability of bin $k$. That normalisation reproduces all three of his tables.
For an arbitrary $p \in [0,1]$ and a triangle with $n$ rows, what is the distribution of balls in bin $k$? Four questions come with it.
- What is the least and the greatest $p$ at which the middle entry of a row equals the extremes, for even rows and for odd rows?
- What changes on a different geometry, a cylinder or a tetrahedron?
- How does this relate to lattice walks?
- Does the distribution converge to a normal law, and with what variance?
All five are answered below with proofs. The middle-against-extremes question and the geometry question each grew into a paper of its own, and those two papers are what the later sections report.
Credit where it belongs. The position of the ball is the correlated random walk of Goldstein and Gillis, and the exact law is the count of binary words by runs that goes back to Wald and Wolfowitz. Neither the law nor the normal limit is new, and Renshaw and Henderson treat this exact walk, though only their abstract was consulted here and the proofs below are self-contained. What we did not find in the sources we looked at are the two lattice-path bijections and the results on $p_N$. Neither OEIS entry mentions the Galton board.
The exact distribution
A run of the experiment with $N$ bounces is a word $w \in \{L,R\}^N$. Let $\operatorname{chg}(w)$ count the places where consecutive letters differ, and put $\operatorname{rep}(w) = N-1-\operatorname{chg}(w)$. The model says
$$\mathbb{P}(w) = \tfrac12\,p^{\operatorname{rep}(w)}q^{\operatorname{chg}(w)},$$so everything reduces to counting words by their number of $R$'s and their number of direction changes.
Let $N \ge 1$. Then $P_N(0) = P_N(N) = \tfrac12p^{N-1}$, and for $1 \le k \le N-1$,
$$P_N(k) = \frac12\sum_{j=1}^{N-1}W(N,k,j)\,p^{N-1-j}q^{\,j},$$where, with $a = k$ and $b = N-k$,
$$W(N,k,2i-1) = 2\binom{a-1}{i-1}\binom{b-1}{i-1}, \qquad W(N,k,2i) = \binom{a-1}{i}\binom{b-1}{i-1} + \binom{a-1}{i-1}\binom{b-1}{i}$$counts the words with $a$ letters $R$, $b$ letters $L$ and exactly $j$ direction changes.
A word with $j$ changes is $j+1$ maximal runs, alternately of $R$'s and of $L$'s. If $j+1 = 2i$ there are $i$ runs of each letter and the first letter is free, so the run lengths are a composition of $a$ into $i$ parts together with a composition of $b$ into $i$ parts. If $j+1 = 2i+1$ the word starts and ends with the same letter, and the two choices of that letter give the two terms.
The first few rows come out as $P_2 = (\tfrac p2, q, \tfrac p2)$, then $P_3(1) = P_3(2) = \tfrac12(1-p^2)$, then $P_4(2) = (1-p)(1-p+p^2)$.
For computing, a second route is better. Split by the last direction. Let $R_N(k)$ and $L_N(k)$ be the probabilities of bin $k$ after $N$ bounces with the last bounce to the right, respectively to the left. Conditioning on the last two bounces gives
$$R_N(k) = p\,R_{N-1}(k-1) + q\,L_{N-1}(k-1), \qquad L_N(k) = p\,L_{N-1}(k) + q\,R_{N-1}(k),$$with $R_1(1) = L_1(0) = \tfrac12$. Solving that linear system for the generating functions is one application of Cramer's rule.
and for all $N \ge 2$, writing $P_M(k) = 0$ outside $0 \le k \le M$,
$$P_N(k) = p\bigl(P_{N-1}(k) + P_{N-1}(k-1)\bigr) - (2p-1)P_{N-2}(k-1).$$At $p = \tfrac12$ the last term vanishes and this is Pascal's rule with weights $\tfrac12$. The memory of the board is that one correction term, reaching two rows up.
Two tables of lattice paths
Multiply the word probability by $2(\alpha+\beta)^{N-1}$ and Kagey's numerators become a weighted count of words.
Let $p = \alpha/(\alpha+\beta)$ with $\alpha,\beta \ge 0$ integers, not both zero. For $N \ge 1$,
$$n_N(k) = \sum_w \alpha^{\operatorname{rep}(w)}\beta^{\operatorname{chg}(w)},$$the sum over the words with $k$ letters $R$ and $N-k$ letters $L$. In particular the numerators are integers.
So $n_N(k)$ counts monotone lattice paths from $(0,0)$ to $(k, N-k)$ in which every straight continuation carries one of $\alpha$ colours and every corner one of $\beta$ colours. That is the general answer to the lattice-walk question. The two tables Kagey singles out are the cases where a colour can be traded for geometry.
Let $T(a,b)$ be the number of ways a rook reaches $(a,b)$ from $(0,0)$ by moves that increase one coordinate by a positive amount. Then for $p = \tfrac23$, $n_N(k) = T(k, N-k)$. Kagey's $p = \tfrac23$ table read by rows is A035002 read by antidiagonals.
Send a rook path to a word by replacing a move of length $\ell$ to the right by $R^\ell$ and a move of length $\ell$ upward by $L^\ell$. The path is then the word together with the set of places where one move ends and the next begins. A break is forced wherever consecutive letters differ and optional wherever they agree, and every choice of the optional breaks comes from exactly one rook path. Hence $T(a,b) = \sum_w 2^{\operatorname{rep}(w)}$, which is the proposition at $(\alpha,\beta) = (2,1)$.
Call a lattice point $(x,y)$ blocked if $x \equiv y \equiv 1$ or $x \equiv y \equiv 2 \pmod 3$, and let $M(a,b)$ count the walks from $(0,0)$ to $(3a,3b)$ with unit right and up steps that visit no blocked point. Then for $p = \tfrac13$, $n_N(k) = M(k, N-k)$. The array $M$ is symmetric, and A348595 lists its lower triangle.
Reduce coordinates modulo $3$ and call a point with residue $(0,0)$ a corner. From a corner a right step is forced onward to residue $(2,0)$, a state we call $\mathsf A$, and by symmetry an up step is forced onward to residue $(0,2)$, a state $\mathsf B$. Neither move crosses a line $x \equiv 0$ or $y \equiv 0$. From $\mathsf A$ the walk either steps right onto a corner or goes up, right, up onto $\mathsf B$, and either way it crosses exactly one line $x \equiv 0$. From $\mathsf B$ it crosses exactly one line $y \equiv 0$ and lands on a corner or on $\mathsf A$. So a walk from $(0,0)$ to $(3a,3b)$ spells a word with $a$ letters $R$ and $b$ letters $L$. Between two equal letters it must pass through a corner, which it can do in one way. Between two unequal letters it may pass through a corner or go directly, which is two ways. Hence $M(a,b) = \sum_w 2^{\operatorname{chg}(w)}$, which is the proposition at $(\alpha,\beta) = (1,2)$.
The two bijections put the freedom in opposite places. For rook paths the word fixes the route and the choice is where to stop. For blocked walks the stops are fixed and the choice is the route.
Variance and the normal limit
Write $e_i = +1$ if the $i$-th bounce is to the right and $-1$ otherwise, put $X_N = e_1 + \cdots + e_N$, and let $K_N = (N+X_N)/2$ be the bin index. Then $e_{i+1} = e_is_i$ where the $s_i$ are independent of each other and of $e_1$ with $\mathbb{P}(s_i = 1) = p$. So $\mathbb{E}e_i = 0$ and $\mathbb{E}e_ie_{i+m} = \rho^m$ with $\rho = 2p-1$, and summing two geometric series gives the variance.
$\mathbb{E}K_N = N/2$, and for $p < 1$,
$$\operatorname{Var}K_N = \frac{Np}{4(1-p)} - \frac{(2p-1)\bigl(1-(2p-1)^N\bigr)}{8(1-p)^2}.$$For $p = 1$, $\operatorname{Var}K_N = N^2/4$.
Persistence inflates the binomial variance $N/4$ by the factor $p/(1-p)$, and the correction term is bounded in $N$. The limit law follows from the same two-state structure.
Let $0 < p < 1$. Then $(K_N - N/2)/\sqrt N$ converges in distribution to the normal law with mean $0$ and variance $p/(4(1-p))$.
Let $v_N$ hold $\mathbb{E}[e^{i\theta X_N}; e_N = \pm1]$. The recursion above gives $v_{N+1} = Mv_N$ with $\operatorname{tr}M = 2p\cos\theta$ and $\det M = p^2-q^2 = \rho$, so the eigenvalues are $\lambda_\pm = p\cos\theta \pm \sqrt{q^2 - p^2\sin^2\theta}$. They are real and distinct for $|\sin\theta| < q/p$, and there $\varphi_N = c_+\lambda_+^{N-1} + c_-\lambda_-^{N-1}$. As $\theta \to 0$, $\lambda_- \to \rho$ and $c_- \to 0$, while
$$\lambda_+(\theta) = 1 - \frac{p}{2q}\theta^2 + O(\theta^4).$$Put $\theta = s/\sqrt N$. Since $|\rho| < 1$ the second term dies, the first tends to $\exp(-ps^2/2q)$, and Lévy's continuity theorem finishes it. Finally $K_N - N/2 = X_N/2$.
Both endpoints are genuinely excluded. At $p = 1$ the ball sits in bin $0$ or bin $N$ with probability $\tfrac12$ each, and at $p = 0$ it sits in a middle bin.
Middle against extremes
Let $m_N = \lfloor N/2\rfloor$, which is a middle bin, and put $u = q/p$. Dividing the bin-probability theorem by $P_N(0)$ turns the question into one about a polynomial,
$$\frac{P_N(m_N)}{P_N(0)} = S_N(u) := \sum_{j=1}^{N-1}W(N,m_N,j)\,u^j,$$with nonnegative integer coefficients and linear coefficient $2$.
For every $N \ge 2$ there is exactly one $p = p_N$ in $[0,1]$ with $P_N(m_N) = P_N(0)$, and the middle is more likely than the extremes below $p_N$ and less likely above it. Moreover $p_2 = \tfrac23$, $p_3 = 1/\sqrt2$, $p_4$ is the real root of $3p^3-4p^2+4p-2$, the sequence $p_N$ is strictly increasing, and $1-p_N \sim (\log N)/N$.
Uniqueness is immediate once the equation is written as $S_N(u) = 1$, because $S_N$ is continuous and strictly increasing on $[0,\infty)$ with $S_N(0) = 0$ and $S_N(u) \ge 2u$. Monotonicity is a comparison of coefficients. Passing from $N$ to $N+1$ turns the middle pair $(a,b)$ into $(a+1,b)$ or into $(a,b+1)$, the formulas are symmetric in $a$ and $b$, and every binomial coefficient $\binom{a-1}{\cdot}$ is nondecreasing in $a$. The coefficient of $u^2$ is $N-2$, which increases strictly. So $S_{N+1} > S_N$ on $u > 0$ and the root moves left.
In Kagey's terms the answer is this. Each row has exactly one such $p$, so within a row there is no least and no greatest. Across rows of one parity the least value is $p_2 = \tfrac23$ for the odd-numbered rows, which is why the third row of his $p = \tfrac23$ table is $2,2,2$, and $p_3 = 1/\sqrt2$ for the even-numbered rows from the fourth on, the second row being $1,1$ for every $p$. There is no greatest value, because $p_N$ increases to $1$. The tenth row has $p_9 = 0.82829\ldots$, just under $\tfrac56$, which is why the extremes and the middle are nearly level in his third histogram.
| $N$ | $p_N$ | $N$ | $p_N$ |
|---|---|---|---|
| 2 | 0.66666667 | 10 | 0.83840411 |
| 3 | 0.70710678 | 11 | 0.84652725 |
| 4 | 0.74487450 | 12 | 0.85426060 |
| 5 | 0.76759188 | 20 | 0.89293837 |
| 6 | 0.78871211 | 50 | 0.94200405 |
| 7 | 0.80361731 | 100 | 0.96496633 |
| 8 | 0.81759938 | 200 | 0.97939018 |
| 9 | 0.82829163 | 400 | 0.98812464 |
The asymptotic is right and slow. The ratio $N(1-p_N)/\log N$ is $0.70$ at $N = 10$, $0.76$ at $N = 100$, $0.79$ at $N = 400$ and $0.83$ at $N = 3200$.
Rescaling the polynomial gives $\tfrac N2S_N\bigl(x/(N/2)\bigr) \to 2x\bigl(I_0(2x)+I_1(2x)\bigr)$, which suggests approximating $u_N = (1-p_N)/p_N$ by $x_B/(N/2)$, where $x_B$ solves $2x\bigl(I_0(2x)+I_1(2x)\bigr) = N/2$. That was a guess for a long time, because the relevant $x$ grows like $\tfrac12\log N$ and the bounds available here do not survive that. Paper A proves it.
Write $z_N = N(1-p_N)$ and let $\zeta_N = \tfrac12W_0(\pi N^2/4)$ be the root of $8\zeta e^{2\zeta} = \pi N^2$. Then for every $N \ge 2$,
$$\zeta_N + \frac1{8\zeta_N} - \varepsilon_N \;<\; z_N \;<\; \zeta_N + \frac1{8\zeta_N}, \qquad \varepsilon_N = \frac{\zeta_N(\zeta_N+1)}{N} + \frac1{16\zeta_N^2}.$$The two bounds close on each other, so the crossing is trapped in an explicit interval at every board size rather than only for large $N$. Expanding gives exactly the formula guessed above,
$$N(1-p_N) = \log N - \tfrac12\log\log N + \tfrac12\log(\pi/8) + o(1),$$and $\tfrac12\log(\pi/8) = -0.467\ldots$ is the constant that accounts for the slow convergence.
The route is a comparison of the central bin with a modified Bessel function, carrying an error bound explicit in $N$. It is analytic for $N \ge 175$ and exact integer arithmetic below that, with the finite range cross-verified in Lean. The approximation was tested before it was proved: on the data available when it was written down the ratio $u_B/u_N$ was $0.9761$ at $N = 100$, $0.9864$ at $N = 200$ and $0.9924$ at $N = 400$, and windows of $[0.9950,0.9970]$, $[0.9970,0.9985]$ and $[0.9983,0.9992]$ at $N = 800, 1600, 3200$ were registered in the repository ledger before those three roots were computed. The computed ratios were $0.99579$, $0.99769$ and $0.99874$, all inside their windows.
Other geometries
This was the half-answered question, and Paper B answers it. Give each peg $d \ge 2$ directions. The first bounce is uniform, and afterwards the ball repeats its direction with probability $p$ and takes each other direction with probability $q/(d-1)$. For $d = 3$ the pegs form a tetrahedral pile and the bins of layer $N$ are indexed by $(k_1,k_2,k_3)$ with $k_1+k_2+k_3 = N$.
Put $\sigma = (dp-1)/(d-1)$ and $A = \sum_{i=1}^{d}x_it/(1-\sigma x_it)$. Then
$$\sum_{N \ge 0}\ \sum_{k_1+\cdots+k_d = N}P_N(k_1,\dots,k_d)\,x_1^{k_1}\cdots x_d^{k_d}\,t^N = 1 + \frac{A/d}{1 - \frac{q}{d-1}A}.$$At $d = 2$ this is the generating function for the flat board. The same conditioning gives the covariance of the direction counts,
$$\operatorname{Cov}(K_a,K_b) = \Bigl(\frac{\delta_{ab}}{d}-\frac1{d^2}\Bigr)\Bigl(N\,\frac{1+\sigma}{1-\sigma} - \frac{2\sigma(1-\sigma^N)}{(1-\sigma)^2}\Bigr),$$so the multinomial covariance is inflated by the factor $(d-2+dp)/(d(1-p))$, which is $(1+3p)/(3(1-p))$ for the tetrahedron.
There is still no closed form for the tetrahedral bin probabilities to set beside the bin-probability theorem. Paper B does without one. The bins after $N$ steps are the lattice points of a simplex, a segment at $d = 2$ and a triangle at $d = 3$, and only a ball that never turns reaches a corner, so each corner has probability $p^{N-1}/d$. Write $r = (1-p)/(d-1)$ for the chance of any one turn, $T = Nr$ for the expected number of turns, and $L = \log N$. A face spanned by $k$ of the directions carries its mass spread over about $(N/\sqrt T)^{k-1}$ bins near its own centre, so
$$\frac{\text{central bin of the face}}{\text{corner}} \;\approx\; \text{const}\cdot\Bigl(\frac{e^T\sqrt T}{N}\Bigr)^{k-1}.$$The bracket does not depend on $k$. Every face therefore draws level with the corners at the same place, when $T + \tfrac12\log T = L + O(1)$, and only the constant in front can tell the faces apart. That constant is $e^{-(k-1)a_k}$, the mass $k$ of the face divided by the Gaussian volume of its fluctuations, and the $a_k$ are strictly decreasing.
Put $\Psi = T - L + \tfrac12\log T$, which increases as $p$ falls. The centre of the whole simplex reaches the corners first, at $\Psi = a_d$, and at that moment a face spanned by $k < d$ directions is still below them by the factor $e^{-(k-1)(a_k-a_d)}$. Past it the centre beats every proper face. So on a long board, as the expected number of turns grows to any fixed multiple of $\log N$, the most likely bin jumps exactly once, from the corners straight to the centre, with no edge or other proper face holding it in between.
On the triangle that factor is $e^{-(a_2-a_3)} = 0.827$, so the middle bin overtakes the corners while the midpoints of the edges are still about 17 per cent below them. The jump is visible already at $N = 24$. It is not forced: a nonuniform start, or a weak external field favouring one direction, moves the constants and can let an intermediate face win instead.
What is still not written out is the normal limit for $d \ge 3$ that the central limit theorem for finite Markov chains leads one to expect.
The cylinder is easier. The local rule does not change, so the position is $X_N$ modulo $2c$ on a cylinder with $c$ pegs to a row, and the discrete Fourier coefficients of its law are $\varphi_N(\pi l/c)$ for $0 \le l < 2c$. For $0 < p < 1$ and $\theta \notin \pi\mathbb{Z}$ both eigenvalues have modulus below $1$, the real ones because $|\lambda_\pm| \le p|\cos\theta| + q$ and the complex ones because their modulus is $\sqrt\rho$. The coefficients at $l = 0$ and $l = c$ are $1$ and $(-1)^N$. So the law approaches the uniform law on the $c$ positions of the right parity, geometrically fast, and there is no normal shape in the limit.
What was checked
Every statement above was computed at least two ways before it was written down.
- $P_N$ is produced three ways in exact rational arithmetic: the closed form, the two-state recursion, and enumeration of all $2^N$ words. The three agree and the rows sum to $1$ for $N \le 16$ at twenty values of $p$. Since $P_N(k)$ is a polynomial of degree less than $N$ in $p$, that is an identity in $p$.
- The numerators reproduce rows $1$ to $9$ of all three tables in Kagey's figure. The $p = \tfrac23$ numerators equal the $60$ published terms of A035002 and a direct count of rook paths. The $p = \tfrac13$ numerators equal the $55$ published terms of A348595 and a direct count of the blocked walks.
- Both bijections were checked word by word, not just in total. Each of the twenty words with three $R$'s and three $L$'s comes from exactly $2^{\operatorname{rep}}$ rook paths and $2^{\operatorname{chg}}$ blocked walks, and the totals are $106$ and $212$.
- The variance formula agrees exactly with the moments of the computed distribution, and the tetrahedral covariance with enumeration of all $3^N$ words for $N \le 9$. At $N = 2000$ the distribution function of $K_N$ is within $1.1\times10^{-4}$ of the limiting normal one, with a continuity correction, for $p = \tfrac13, \tfrac23, \tfrac56$.
- Each $p_N$ in the table is the root of $S_N$ found by bisection in integer arithmetic, then confirmed by evaluating the recursion exactly at the two ten-digit neighbours of the root. Monotonicity was confirmed for $N \le 121$ before it was proved.
- The finite range of Paper A, the part below $N = 175$ that the analytic argument does not cover, is carried by exact integer arithmetic and cross-verified in Lean, so the two halves of the proof rest on different machinery.
One thing failed. A closed form for the row-5 difference written down by hand, $(1-p)(1-p+2p^2) - p^3/2$, did not survive the exact check on its first run. The correct polynomial is $(1-p)(1-p+p^2)-p^3/2$, which makes $p_4$ the root of $3p^3-4p^2+4p-2$. The repository ledger records that, along with the two statements that were read off from data and registered before they were tested.