Distribution of leftover cookies in one of the jars when another one is emptied You have two jars of cookies, jar 1 and jar 2. Each jar starts with $n$ cookies initially. Every day,
when you come home, you pick one of the two jars randomly (each jar is chosen with probability
$1/2$). One day, you come home and reach inside one of the jars of cookies, but you find that is
empty! Let $X$ denote the number of remaining cookies in the other jar. What is the distribution of
$X$?
 A: Identify the jars so they can be distinguished. Let the numbers of cookies in those jars be $X$ and $Y$, respectively.  At each step $(X,Y)$ changes to $(X-1,Y)$ or $(X,Y-1)$ with equal chances, provided both $X$ and $Y$ are nonzero.  This describes a symmetric random walk in the plane$^*$ starting at $(X,Y)=(n,n)$.  It ends when the walk first encounters the absorbing barrier where $X=0$ or $Y=0$. The analysis is straightforward.  Details follow, along with a simple worked example and a large-$n$ approximation.
$^*$Actually it's a symmetric (discrete) walk on the line with coordinate $X-Y$, starting at the origin, with a somewhat complicated absorbing barrier.  The imagery of moving from one lattice point to another in the plane, though, makes the analysis particularly simple to follow and the absorbing barrier easier to picture.

Suppose the walk ends at $(K,0)$. Because this is where a coordinate of $0$ was first reached, the previous position had to have been $(K,1)$ with $K \gt 0$.  To arrive at $(K,1)$ from $(n,n)$ took $(n-K)+(n-1)=2n-K-1$ steps of probability $1/2$ each, of which $n-1$ were in the second coordinate.  The total number of such paths, all with length $2n-K-1$ and (therefore) equal probability $(1/2)^{2n-K-1}$, is the number of ways of choosing the steps taken in the second coordinate, equal to $\binom{2n-K-1}{n-1}$.  Including the $1/2$ chance of the final step to $(K,0)$, we have found that the chance of ending at $(K,0)$ is
$$\Pr(K,0) = \binom{2n-K-1}{n-1}2^{K-2n}.$$
The symmetry in the roles of the jars shows immediately that
$$\Pr(X,Y) = \Pr(Y,X).$$
Since the ways in which the number of remaining cookies can be $K$ correspond to the distinct outcomes $(K,0)$ and $(0,K)$, whence the chance of having $K$ cookies at the end is
$$\Pr(K,0) + \Pr(0,K) = 2\Pr(K,0) = \binom{2n-K-1}{n-1}2^{1+K-2n}.$$
For instance, with $n=3$ cookies per jar, the probabilities are
$$\eqalign{\Pr(1) &= \binom{6-1-1}{2}2^{2-6} = \frac{6}{16} = \frac{3}{8}\\
\Pr(2)&=\binom{6-2-1}{2}2^{3-6} = \frac{3}{8}\\
\Pr(3)&=\binom{6-3-1}{2}2^{4-6} = \frac{1}{4}.
}$$

This distribution is approximately half-Normal.  Because its mean is $$\mu = (2n-1)2^{2-2n}\binom{2n-2}{n-1},$$ the half-Normal standard deviation parameter is approximately $\mu / \sqrt{2/\pi}$.  This provides a decent approximation for large $n$.  For instance, with $n=1000$, $\mu=35.678$, implying a standard deviation parameter of $44.72$ for the approximating half-Normal distribution.  The chance of (say) $K \ge 60$ would be approximated using the standard Normal distribution function $\Phi$ as
$$\Pr(K \ge 60) \approx 2\left(1 - \Phi\left(\frac{60-0.5}{44.72}\right)\right) =0.1833$$
whereas the correct value is  $0.1804$.

The black graph traces the correct probabilities for $n=1000$ while the dotted red graph is the approximating Normal density.
A: I presume that $X$ is supposed to be the number of cookies in the other jar (the one you didn't just find was empty). Then $X$ has a negative hypergeometric distribution, where the total number of elements is $2n$, the total number of successes is $n$, and the number of failures before the experiment is stopped is $n$. The probability mass function for $X = k$ comes out to
$$\frac{ {n+k-1}\choose{k} }{ {2n}\choose{n} } \quad .$$
