Published
In this lesson
Wide tables, equations, and code scroll sideways. Swipe, or Tab to focus them and use the left and right arrow keys.
Ehrenfest urn
You will learn: Distinguish stationarity from convergence by tracking parity and holding probabilities.
Start with: Markov chains
Ten balls begin in the right urn. At each step choose one of the ten uniformly and move it to the opposite urn. Crowded urns lose balls more often, so the left count tends toward the middle. Does its distribution converge to a binomial curve? Not if every step must move a ball: the count alternates between even and odd.
This small model separates three ideas that can otherwise look interchangeable: a sample path fluctuating near equilibrium, a stationary probability distribution, and convergence to that distribution from a fixed initial state.
Compare the current law with equilibrium
Filled left bars: distribution after 30 steps from state 0. Open right bars: Binomial(10, 1/2), a stationary reference. Total-variation distance 0.50000000; expected left count 4.9938103.
Every step changes parity. Only even left counts are reachable now. From this fixed initial state, the distribution cannot converge to the full stationary binomial.
This realization's final ball counts are 4 on the left and 6 on the right. It is one path; the bars summarize all possible paths.
Inspect probabilities and path
| Left count | Current probability | Stationary probability |
|---|---|---|
| 0 | 0.001977323 | 0.0009765625 |
| 1 | 0.000000 | 0.009765625 |
| 2 | 0.08854370 | 0.04394531 |
| 3 | 0.000000 | 0.1171875 |
| 4 | 0.4111715 | 0.2050781 |
| 5 | 0.000000 | 0.2460938 |
| 6 | 0.4091405 | 0.2050781 |
| 7 | 0.000000 | 0.1171875 |
| 8 | 0.08723806 | 0.04394531 |
| 9 | 0.000000 | 0.009765625 |
| 10 | 0.001928966 | 0.0009765625 |
0, 1, 2, 1, 0, 1, 2, 1, 2, 1, 2, 1, 2, 3, 4, 5, 6, 5, 6, 5, 6, 5, 4, 5, 4, 3, 4, 3, 2, 3, 4
The state k is the number of balls in the left urn, with N − k on the right. A move decreases k with probability k/N and increases it with probability (N − k)/N. The optional holding probability h leaves the state unchanged; otherwise a uniformly selected ball moves. No balls enter or leave the system.
The filled bars propagate all possible states from the chosen initial count. The open bars show the binomial stationary reference. The lower plot is one seeded realization, so its final count need not equal the exact expectation. Increasing the step count retains that realization’s existing prefix.
Work through two steps
Use N = 2, start = 0, and h = 0. After one step the left count is certainly one. After the second step either the same ball moves back or the other ball moves left, each with probability one half. The distribution is therefore (1/2, 0, 1/2). At every odd step the count is again exactly one; at every positive even step the distribution returns to (1/2, 0, 1/2).
The stationary reference is Binomial(2, 1/2), or (1/4, 1/2, 1/4). Neither alternating distribution approaches it. Their total-variation distance is one half: add the absolute differences in each state’s probability and divide by two. A visually central mean does not imply a matching distribution.
Now set h = 1/2. After one step the distribution from zero is (1/2, 1/2, 0). After two steps it becomes (3/8, 1/2, 1/8), with total-variation distance 1/8 from the binomial reference. Both parities are possible at a given time because some histories include a hold.
Why the binomial is stationary
Imagine assigning each labeled ball independently to the left or right with equal probability. The number on the left is binomial. Flipping the side of a uniformly selected ball preserves that uniform distribution over all labeled assignments, so it preserves the induced binomial count distribution too. Holding preserves it as well.
Equivalently, with π(k) = C(N,k)/2ᴺ, the probability flowing from k to k + 1 in equilibrium is π(k)(N − k)/N. It equals the reverse flow π(k + 1)(k + 1)/N. These equal flows verify stationarity. They do not assert that a deterministic initial assignment was already at equilibrium.
Means, parity, and time
Given k balls on the left, the expected change is (1 − h)(1 − 2k/N). Taking expectations gives a linear recurrence. From initial count k₀, the exact mean after t steps is N/2 + (k₀ − N/2)(1 − 2(1 − h)/N)^t. The displayed expectation uses this formula and is checked against the propagated probabilities.
When h = 0, every move changes the parity of k, so only one parity is reachable at each fixed time. The full binomial gives total probability one half to each parity, leaving an unavoidable distance of at least one half. When 0 < h < 1, both holding and moving remain possible; this finite irreducible, aperiodic chain converges to the binomial. At h = 1 it freezes entirely, and there is no unique attracting distribution.
Make a prediction
Does a stationary binomial distribution mean that every long trajectory ends with exactly N/2 balls on the left?
Explore the answer
No. Stationarity is a statement about a distribution over states. Individual trajectories continue to fluctuate, and N/2 is not even an integer when N is odd.
Siegrist’s Ehrenfest-chain notes give the transition and recurrence theory. Compare Pólya’s urn: it changes the composition by adding balls, whereas this model conserves a fixed total and transfers balls. The general vocabulary appears in Markov chains.