# If $n$ balls are distributed randomly into $k$ urns, what is the probability that the last urn contains $j$ balls?

This is a homework question I was assigned to do. I was thinking about the problem and I thought the answer was $$\frac{1}{k^j} \cdot \left(1 - \frac{1}{k}\right)^{n-j} .$$ I now have some doubts, though. I was thinking that I am not taking into account that the balls could be distributed into the urns in different combinations, so perhaps I have to include some expression involving ${{A}\choose{B}}$, where $A$ and $B$ are some expressions involving $n, k$ or $j$ ?

-

As a first hint, look into "stars and bars" problems, perhaps searching for stars and bars here.

As a second hint, the number of ways to do it where $j$ balls end up in the last urn is the same as the number of ways to put $n-j$ balls into $k-1$ urns.

-

The answer depends on whether the balls are distinguishable or not. If they are not, which is almost certainly what is intended, Isaac’s answer points the way.

If they are, the reasoning is a bit different. Your expression gives the probability that a particular set of $j$ balls goes into the last urn and the other $n-j$ balls into the other urns. But there are $\binom{n}j$ different possible sets of $j$ balls, and each of them the same probability of being the final contents of the last urn, so the total probability of ending up with exactly $j$ balls in the last urn is $$\binom{n}j\left(\frac1{k^j}\right)\left(1-\frac1k\right)^{n-j}=\binom{n}j\cdot\frac{(k-1)^{n-j}}{k^n}$$ if the balls are distinguishable.

Mind you, I include this answer only for the sake of completeness: it’s much more likely that you’re supposed to assume that the balls are indistinguishable.

-