Bernoulli-Laplace diffusion model (source code)

= Bernoulli-Laplace diffusion model
{c}
{title2=$P(r,r+1)=(n-r)^2/n^2,\quad P(r,r-1)=r^2/n^2$}

In the <Bernoulli-Laplace diffusion model>, two urns each contain $n\geq1$ balls, with $n$ red and $n$ blue balls in total. Independently choose one ball uniformly from each urn and exchange them. The red count $R_k$ in the first urn is a <Markov chain> on $\{0,\ldots,n\}$, with
$$
P(r,r+1)=\frac{(n-r)^2}{n^2},\qquad
P(r,r-1)=\frac{r^2}{n^2},\qquad
P(r,r)=\frac{2r(n-r)}{n^2}.
$$
The upward <event> exchanges a blue ball from the first urn with a red ball from the second; the downward <event> reverses the colors. Hence
$$
\mathbb E[R_{k+1}\mid R_k=r]=1+(1-2/n)r.
$$
Starting from $R_0=n$, the <mean> is $n/2+(n/2)(1-2/n)^k$, with the initial value understood separately if the geometric factor is zero. For $n\geq2$, this <mean> tends to $n/2$. For $n=1$, however, the only two configurations alternate and the expected imbalance does not decay.

The <Stationary distribution> is the <hypergeometric distribution>
$$
\pi(r)=\frac{\binom nr^2}{\binom{2n}n}.
$$
It counts uniformly allocated red/blue configurations. The ratio $\pi(r+1)/\pi(r)=[(n-r)/(r+1)]^2$ verifies <Detailed balance> with the displayed transitions. The chain is <irreducible Markov chain>[irreducible]; for $n\geq2$ an interior holding <Probability> also makes it <aperiodic Markov chain>[aperiodic], while the $n=1$ chain has period two. This model separates convergence of an average imbalance from the full <probability law> and its periodicity.