[Math] Probability of $n$ balls in $n$ cells

probability

If $n$ balls are randomly placed into $n$ cells, find the probability that exactly one cell remains empty.

So the denominator is $n^n$. I can pick the empty cell in $n$ ways. There are $n-1$ cells that can have $k$ balls. There are $\binom{n}{k}$ ways of picking the $k$ balls to go into this cell. Also there are $(n-k) \cdots (n-2)$ ways of placing the remaining $n-k$ balls into the $n-2$ cells. So the product of this is $n(n-1) \binom{n}{k} [(n-k) \cdots (n-2)]$

So the answer is $$\frac{n(n-1) \binom{n}{k} [(n-k) \cdots (n-2)]}{n^n}$$

Is this right?

Best Answer

I'm not sure you're correct (what is k?).

If everything is distinct:

There are $n$ ways to choose the empty cell. There will be exactly one other cell with more than one ball in it; in fact, exactly two balls in it. There are $$\underbrace{ (n-1)}_{\text{choose}\atop\text{urn}}\cdot \underbrace{( n (n-1)/2)}_{\text{choose the }\atop\text{two balls}}$$ ways to chose and fill this cell. Since exactly one cell is empty, there are $(n-2)!$ ways to distribute the remaining $n-2$ balls (the cells are being thought of as distinct, and each of the remaining $n-2$ cells gets exactly one of the remaining $n-2$ balls; so the number of ways of distributing the remaining $n-2$ balls is just the number of ways to arrange $n-2$ objects).

So the probability is $${n\cdot( (n-1) n(n-1)/2)(n-2)!\over n^n}={(n-1)(n-1)!\over2\, n^{n-2}}.$$