Skip to content

The Ehrenfest urn

Posted on:

Take NN balls numbered 11 to NN and two urns, A and B. Every second, draw a number uniformly at random from 11 to NN and move the ball with that number to the other urn. Start with all NN balls in A. The count in A drops, at first by nearly one ball per step, then more slowly, and settles into fluctuations around N/2N/2 that never stop. Run the film backward and the same rule describes it: the process is reversible, and every configuration, the starting one included, is revisited eventually with probability one. This is the Ehrenfest urn, proposed by Paul and Tatiana Ehrenfest in 1907 as a model in which the approach to equilibrium and the recurrence of the initial state can both be computed, and in which the apparent conflict between them turns out to be a statement about time scales. Every quantity below is exact.

A walk on the corners of the cube

The state of the system is the set of balls in A, a binary vector x{0,1}Nx \in \{0,1\}^N with xi=1x_i = 1 when ball ii is in A. One step flips one uniformly chosen coordinate. So the urn process is the simple random walk on the corners of the NN-dimensional cube, each corner joined to its NN neighbors at Hamming distance 11, and the number of balls in A is the Hamming weight of the current corner, the level \ell of the post on the spiky cube.

Every corner has the same number of neighbors, so the stationary distribution of the walk is uniform over the 2N2^N corners, and the stationary distribution of the count XtX_t of balls in A is the number of corners at each level, normalized:

πk=(Nk)2N,k=0,1,,N.\pi_k = \binom{N}{k} 2^{-N}, \qquad k = 0, 1, \ldots, N.

The equilibrium of the urn is the binomial distribution, the spiky cross-section of the earlier post: in the long run the process spends time at level kk in proportion to the width of that drawing at level kk. The count itself is a Markov chain on {0,,N}\{0, \ldots, N\}, moving from kk to k1k-1 with probability k/Nk/N (a ball in A was drawn) and to k+1k+1 with probability (Nk)/N(N-k)/N. That π\pi is stationary for it is the detailed balance identity (Nk)(Nk)=(Nk+1)(k+1)\binom{N}{k}(N-k) = \binom{N}{k+1}(k+1), whose two sides both count the edges of the cube between levels kk and k+1k+1.

The binomial has mean N/2N/2 and standard deviation N/2\sqrt{N}/2. For N=100N = 100 the equilibrium count is 50±550 \pm 5; the stationary probability of finding 7070 or more balls in A is 3.9×1053.9 \times 10^{-5}, and of finding all 100100 there, 21007.9×10312^{-100} \approx 7.9 \times 10^{-31}. In equilibrium, the state the process was started in is, together with its mirror image, the least probable state there is.

The mean relaxes exponentially

From level kk, the next count is k1k - 1 with probability k/Nk/N and k+1k + 1 otherwise, so

E[Xt+1Xt=k]=kkN+NkN=(12N)k+1.\mathbb{E}[X_{t+1} \mid X_t = k] = k - \frac{k}{N} + \frac{N - k}{N} = \Big(1 - \frac{2}{N}\Big) k + 1.

The same recursion holds for the imbalance XtN/2X_t - N/2. Subtract N/2N/2 from both sides and use 1N2=(12N)N21 - \tfrac{N}{2} = -\big(1 - \tfrac{2}{N}\big)\tfrac{N}{2} to get

E[Xt+1N2Xt]=(12N)(XtN2).\mathbb{E}\Big[X_{t+1} - \frac{N}{2} \,\Big|\, X_t\Big] = \Big(1 - \frac{2}{N}\Big)\Big(X_t - \frac{N}{2}\Big).

Iterating, E[Xt]N/2=(12/N)t(X0N/2)\mathbb{E}[X_t] - N/2 = (1 - 2/N)^t\,(X_0 - N/2). The expected imbalance between the urns decays geometrically, with time constant N/2N/2 steps. This is Newton’s law of cooling for two bodies exchanging heat, and it has been obtained from a reversible rule by taking an expectation; nothing irreversible was put in. Starting from all balls in A, the expected imbalance N/2N/2 shrinks to the size of the equilibrium fluctuations, N/2\sqrt{N}/2, after tN4lnNt \approx \frac{N}{4}\ln N steps: about 115115 steps for N=100N = 100. The same 14NlnN\frac14 N \ln N is the mixing time of the cube walk: Diaconis, Graham and Morrison (1990) proved that the walk (in a version allowed to stay put) is far from uniform before 14NlnN\frac14 N\ln N steps and close to uniform shortly after.

The factor 12/N1 - 2/N is the second largest eigenvalue of the transition matrix, and the full spectrum is also explicit. On the cube, the walk is diagonalized by the parity functions χS(x)=(1)iSxi\chi_S(x) = (-1)^{\sum_{i \in S} x_i}, one for each subset SS of coordinates: flipping a random coordinate changes the sign of χS\chi_S exactly when the coordinate lies in SS, which happens with probability S/N|S|/N, so χS\chi_S is an eigenvector with eigenvalue 12S/N1 - 2|S|/N. The eigenvalues of the count chain are therefore

λj=12jN,j=0,1,,N,\lambda_j = 1 - \frac{2j}{N}, \qquad j = 0, 1, \ldots, N,

a result of Kac (1947), and on the cube the eigenvalue λj\lambda_j has multiplicity (Nj)\binom{N}{j}: the binomial coefficient appears a third time, now as a spectral multiplicity. The second moment obeys a recursion of the same kind, E[Xt+12Xt=k]=(14/N)k2+2k+1\mathbb{E}[X_{t+1}^2 \mid X_t = k] = (1 - 4/N)k^2 + 2k + 1, with λ2=14/N\lambda_2 = 1 - 4/N as its factor, so the variance of the count at every time is also a closed computation, and the widget below uses both recursions.

Reversibility gives a statement about the past as well. In the stationary process, detailed balance means the film run backward has the same law as the film run forward, so P(Xts=jXt=k)=P(Xt+s=jXt=k)\mathbb{P}(X_{t-s} = j \mid X_t = k) = \mathbb{P}(X_{t+s} = j \mid X_t = k) for every jj, kk, and ss, and in particular

E[XtsXt=k]=N2+(12N)s(kN2)=E[Xt+sXt=k].\begin{aligned} \mathbb{E}[X_{t-s} \mid X_t = k] &= \frac{N}{2} + \Big(1 - \frac{2}{N}\Big)^{s}\Big(k - \frac{N}{2}\Big) \\ &= \mathbb{E}[X_{t+s} \mid X_t = k]. \end{aligned}

Conditional on an unusual count now, the expected past is the mirror image of the expected future: the count rose to kk along the same exponential curve it is about to descend. An imbalance observed in equilibrium is, in expectation, the top of a symmetric peak, not the start of a decay. This is the picture Boltzmann gave in his 1896 reply to Zermelo, and here it is a two-line consequence of detailed balance.

Return times

The return times follow from a formula of Kac. For an irreducible Markov chain with stationary distribution π\pi, the expected time to return to a state kk, starting from kk, is

Ek[τk+]=1πk.\mathbb{E}_k[\tau_k^+] = \frac{1}{\pi_k}.

For the proof, run the chain in its stationary regime. For each t1t \ge 1, the event that the most recent visit to kk at or before time 00 occurred exactly t1t - 1 steps ago has probability πkPk(τk+t)\pi_k\,\mathbb{P}_k(\tau_k^+ \ge t) by stationarity. These events are disjoint and, since the chain visits kk infinitely often, their union is certain, so πkt1Pk(τk+t)=1\pi_k \sum_{t \ge 1}\mathbb{P}_k(\tau_k^+ \ge t) = 1, and the sum is Ek[τk+]\mathbb{E}_k[\tau_k^+]. (Periodicity is no obstacle: the count chain alternates parity, and the formula holds regardless.)

For the urn, then,

Ek[τk+]=2N(Nk).\mathbb{E}_k[\tau_k^+] = \frac{2^N}{\binom{N}{k}}.

The all-in-A state returns, on average, after exactly 2N2^N steps. The balanced state returns after 2N/(NN/2)πN/22^N/\binom{N}{N/2} \approx \sqrt{\pi N / 2} steps. As a function of the level, the expected return time is the binomial turned upside down: on a logarithmic scale it is Nlog2log(Nk)N \log 2 - \log \binom{N}{k}, a U with its floor at 12log(πN/2)\tfrac12 \log(\pi N/2) in the middle and its rims at Nlog2N \log 2. The spiky cube, seen through return times, is a valley with two cliffs.

NNreturn to all-in-Areturn to balancedall-in-A to balanced
101,0244.18.9
201.05×1061.05 \times 10^{6}5.721.3
501.13×10151.13 \times 10^{15}8.964.8
1001.27×10301.27 \times 10^{30}12.6146.9

The last column is the expected number of steps to go from the all-in-A state down to the balanced state for the first time, from the standard formula for hitting times of a birth–death chain: the expected time to step from jj to j+1j+1 is 1πjpjijπi\frac{1}{\pi_j p_j}\sum_{i \le j}\pi_i with pj=(Nj)/Np_j = (N-j)/N, and the reverse direction is the mirror image. Summing these over the levels between NN and N/2N/2 gives 146.9146.9 for N=100N = 100; summing the reverse formula from N/2N/2 up to NN gives 1.28×10301.28 \times 10^{30}, a little more than 2N2^N itself. Going down takes a hundred-odd steps and going back up takes 103010^{30}, and both numbers come from the same reversible rule.

With N=20N = 20 balls and one move per microsecond, the initial state recurs about once a second, and the recurrence is observable. With N=50N = 50 and one move per nanosecond, the expected wait is 2502^{50} nanoseconds, thirteen days. With N=100N = 100 it is 4×10134 \times 10^{13} years, three thousand times the age of the universe; a mole of molecules puts NN near 102310^{23}. Recurrence is a theorem, and for NN of macroscopic size it is unobservable. The widget computes the exact mean and variance of the count from the all-in-A start, and the exact return-time landscape, for any NN:

balls N = 100time constant N/2 = 50 steps
exact mean of the count mean ± 2 standard deviations N/2
return to all-in-A: stepsreturn to balanced: stepsall-in-A → balanced: stepsbalanced → all-in-A: steps

The two objections

Boltzmann’s H-theorem of 1872 derived, from the kinetic equation for a dilute gas, a quantity HH that can only decrease in time. Two objections followed. Loschmidt’s, in 1876, is the reversibility objection: the equations of mechanics are symmetric under time reversal, so for every motion in which HH decreases there is a reversed motion in which it increases, and a monotone HH cannot follow from mechanics alone. Zermelo’s, in 1896, is the recurrence objection: by Poincaré’s recurrence theorem (1890), an isolated mechanical system with bounded energy returns arbitrarily close to its initial state, so HH cannot decrease forever. Boltzmann’s replies of 1896 and 1897 made the statistical position explicit: the theorem is about overwhelmingly probable behavior, the recurrence times of macroscopic systems are far longer than any observation, and the HH-curve of a system in equilibrium is a sequence of symmetric fluctuation peaks.

In the urn, each of these statements is a calculation. It is reversible (detailed balance holds), and its expected count nevertheless decays monotonically toward N/2N/2 from any start, with the decay curve’s mirror image as the expected past. It is recurrent, with the initial state returning after exactly 2N2^N steps on average, and 2N2^N steps exceed any feasible observation for NN in the hundreds, while the relaxation takes 14NlnN\frac14 N \ln N steps. The 1907 paper of Paul and Tatiana Ehrenfest was written to exhibit this, and the mathematics was completed by Kac in 1947: the spectrum 12j/N1 - 2j/N in one paper and the recurrence formula 1/πk1/\pi_k in another, both in 1947. Siegert (1949) treated the approach to equilibrium in related gas models. The urn is now a standard textbook example, both of a reversible chain with a computable spectrum and of a chain obtained by projecting a larger one (the cube walk onto the count), in Levin, Peres and Wilmer.

References



Previous Post
Gaps between random points
Next Post
The arcsine law