How many outputs possible when throwing $m$ balls into $n$ bins?

1.7k Views Asked by At

For example, for $3$ balls and $3$ bins we have:

1: 1 2 3 (one ball in every bin)
2: 1 2 2
3: 1 3 3 
4: 2 1 1
5: 2 3 3 
6: 3 1 1
7: 3 2 2
8: 1 1 1 
9: 2 2 2 
10:3 3 3 (three balls in the third bin)

What is theory for it? I mean, that is the name of the formula, to let me read about it. Thanks.

2

There are 2 best solutions below

0
On BEST ANSWER

I suggest you study the Stars and Bars method. In this case, you have three bins (2 bars) and three balls (three stars). This gives 3 + 2 = 5 positions. You can place the 2 bars in any of the 5 positions which gives $\binom{5}{2} = 10$ possibilities or you can place the 3 stars in any of the 5 positions: $\binom{5}{3} = 10$ possibilities:

$$ 1: 0|0|3\rightarrow ||*** \\ 2: 0|1|2\rightarrow |*|**\\ 3: 0|2|1\rightarrow |**|* \\ 4: 0|3|0\rightarrow |***| \\ 5: 1|0|2\rightarrow *||** \\ 6: 1|1|1\rightarrow *|*|* \\ 7: 1|2|0\rightarrow *|**| \\ 8: 2|0|1\rightarrow **||* \\ 9: 2|1|0\rightarrow **|*| \\ 10: 3|0|0\rightarrow ***|| $$

0
On

The number of ways to throw exactly $k$ balls total into $n$ bins without restriction is equal to the number of ways to order $k$ stars and $n-1$ bars in line, where all the stars are identical and all the bars are identical, so the number would be: $$\binom{k+n-1}{n-1}=\binom{k+n-1}{k}$$ As you only need to choose the place for the stars (or the bars). If you want each bin to be non-empty, throw $1$ ball into each first, and then throw the remaining $k-n$ balls, so the number would be $$\binom{(k-n)+n-1}{n-1}=\binom{k-1}{n-1}$$ Now, if I understand your question correctly, you want all possible ways to throw any number of balls into $n$ bins such that each bin would contain at least $1$ ball and at most $m$. Using the above formula, we get: $$\sum_{k=n}^{m\cdot n}\binom{k-1}{n-1}$$