# Calculating transition probabilities for Ehrenfest diffusion

Two containers $A$ and $B$ are placed adjacently to each other and gas passes through a small aperture joining them.

A total of $N(>1)$ molecules is distributed among the containers.

Assume that at each epoch of time one molecule, picked uniformly at random from the $N$ available, passes through this aperture.

Let $X_n$ be the number of molecules in $A$ after $n$ units of time.

Work out the transition matrix and classify the states.

I think that my state space will be the number of molecules in $A$ at time $n$ and so I can define $S = \{0, 1, ..., N\}$. So from here, my matrix is going to represent the number of molecules in $A$. So, for example $P_{11}$ is the probability of picking a molecule from $A$ and putting it back in $A$. This can't happen as the molecule must travel through the aperture. So I get that all $P_{ii} = 0$. Also, we know that if we have $i$ molecules in $A$ at time $t$, then we will either gain a molecule, as this one has been picked from $B$, or lose a molecule, as this has been chosen from $A$. The probability of picked a molecule is $\frac{1}{N}$ and so we can say

$$P_{ij} = \begin{cases} \frac{1}{N} & \text{if } j = i + 1 \\ 1 - \frac{1}{N} & \text{if } j = i - 1 \\ 0 & \text{otherwise} \end{cases}$$

So using this, I got the matrix to be

$$\pmatrix{0 & 1 & 0 & 0 & 0 & ...\\ 1 - \frac{1}{N} & 0 & \frac{1}{N} & 0 & 0 & ... \\ 0 & 1 - \frac{1}{N} & 0 &\frac{1}{N} & 0 &... \\ . & . &. &. &. &. \\ . &. &. &. &. &. \\ 0 & 0 & 0 &0 &... & \frac{1}{N} \\ 0 & 0 & 0 & ... & 1 & 0}$$

But in the answers, instead of having $1$'s in the numerator, they've got $i$'s everywhere. How comes? In words: your state space is $S=\{0,1,\dots,N\}$ and $X_n$ is the number of molecules in the left container at time $n$. The states $0$ and $N$ are special: if you have $0$ $(N)$ molecules in the left container at time $n$, then at time $n+1$ you will have, with certain, $1$ $(N-1)$ molecules in the left container. For $i=1,\dots,N-1$, if you have $i$ molecules in the left container at time $n$, then with probability $i/N$ you will have $i-1$ molecules in the left container at time $n+1$, and with probability $1 - i/N=(N-i)/N$ you will have $i+1$ molecules in the left container at time $n+1$. The transition matrix is
$$P_{ij} = \pmatrix{ 0 & 1 & 0 & 0 & 0 & \dots & 0 & 0 & 0 \\ \frac{1}{N} & 0 & \frac{N-1}{N} & 0 & 0 & \dots & 0 & 0 & 0 \\ 0 & \frac{2}{N} & 0 & \frac{N-2}{N} & 0 & \dots & 0 & 0 & 0 \\ \vdots & \vdots & \vdots & \vdots & \vdots & \vdots & \vdots & \vdots \\ 0 & 0 & 0 & \dots & 0 & \frac{N-2}{N} & 0 & \frac{2}{N} & 0 \\ 0 & 0 & 0 & \dots & 0 & 0 & \frac{N-1}{N} & 0 & \frac{1}{N} \\ 0 & 0 & 0 & \dots & 0 & 0 & 0 & 1 & 0 \\ } \, .$$
Assuming the molecules are indistinguishable (a fairly standard assumption from any quantum treatment) then the set of states is simply the set of integers $\left\lbrace 0,1,\dots,N \right\rbrace$, representing the number of molecules in container A. Because at each epoch a single molecule must make a transition through the aperture, it follows that the transition probability function can be derived from the odds of choosing one molecule at random, whose only distinguishable feature is the container it is from; thus $$p\left(\left. X_{n+1} = k \right| X_n = m \right) = \left\lbrace \begin{array}{11} 1 & m = N \text{ and } k = N - 1 \\ 1 & m = 0 \text{ and } k = 1 \\ \frac{N - m}{N} & 0 < m < N \text{ and } k = m + 1 \\ \frac{m}{N} & 0 < m < N \text{ and } k = m - 1 \\ 0 & \text{otherwise} \end{array} \right.$$ This becomes more apparent by noting that $\frac{m}{N}$ is the probability of choosing a molecule from container A, and $\frac{N-m}{N}$ is the converse probability of choosing a molecule from container B