# $n$ balls are thrown randomly into $k$ bins - how many are empty?

A large number of variants of this question were already asked here, including these - one, two, which are close, but none seem to answer my question.

Assume that $$n$$ balls are thrown randomly and independently into $$k$$ bins.

What is the probability of finding $$x$$ empty bins?

What is the expectation of the number of empty bins?

• possible duplicate of We throwing $m$ balls to $n$ cells.... – MJD Nov 14 '14 at 16:37
• This Question asks not only for the expected number of empty bins, which duplicate's MJD's link, but also for the distribution(?) of numbers of empty bins. It looks like the probability of $k$ specified bins being empty was dealt with before, but this is a (subtly?) different matter, in that $k$ specified bins being empty does not correspond to the only outcome of that many bins empty, and indeed does not exclude there being additional empty bins. There might be room for elaborating on the earlier Answer. – hardmath Nov 14 '14 at 17:27
• @MJD - the other question doesn't consider the distribution itself, hence it is different. I accepted as the solution for the actual distribution in found in Andre's comments. – R B Nov 14 '14 at 19:25
• Sorry, I misread the other answer and thought it did describe the distribution. – MJD Nov 14 '14 at 20:03

We do the expectation, without finding the distribution. Let $X_i=1$ if Bin $i$ is empty, and let $X_i=0$ otherwise. Then the number of empty bins is $X_1+\cdots+X_k$, and the expected number is $E(X_1)+\cdots+E(X_k)$.

The probability Bin $i$ is empty is $\left(\frac{k-1}{k}\right)^n$. Thus $E(X_i)=\left(\frac{k-1}{k}\right)^n$. Multiply by $k$ for the expected number of empty bins.

• Thanks @Andre. Unfortunately, the probability is what I'm really after. – R B Nov 13 '14 at 15:52
• Exactly $x$ or at least $x$? One can write down an Inclusion/Exclusion expression. – André Nicolas Nov 13 '14 at 15:58
• Exactly $x$, and I agree that IE would work. Do you think there exists a closed-form formula for it? – R B Nov 13 '14 at 16:00
• In terms of Stirling numbers of the second kind, yes, but (unless you consider the Stirling number notation a closed form), no. – André Nicolas Nov 13 '14 at 16:03
• For exactly $x$ empty, choose which $x$ it will be. Then you are counting onto functions, and you get Stirling numbers. – André Nicolas Nov 13 '14 at 16:10

The OP is more concerned with the first question, what is the probability of $x$ empty bins.

Let me try. Start with $x=1$. Thus, all remaining $k-1$ bins are NOT empty. The total number of put $n$ balls into $k-1$ bins is standard and many solutions online, the number is $C_{n+k-2}^{k-2}$. This includes the situations that some bins are EMPTY. So if every bin is NOT empty, thus the total number of ways is to put $n-(k-1)$ balls into $k-1$ bins (assume every bin has already 1 ball). It has $C_{n-1}^{k-2}$ ways. Thus, $$Prob(x=1) = n*\frac{C_{n-1}^{k-2}}{C_{n+k-2}^{k-2}}$$ The reason we multiply by $n$ is because of $C_n^1$ ways to choose which box is empty.

I believe other situations for $x$ can be derived in a similar way.

• There are $k$ ways to choose the empty bin, not $n$. Also, try this for $n=2,k=2$: then $C^{k-2}_{n-1}=C^{k-2}_{n+k-2}=1$ and the formula above produces the result $P(x=1) = 2,$ which is absurd. – David K Dec 1 '17 at 20:41