Number of ways to distribute M balls into N boxes with limited size V

394 Views Asked by At

I am trying to figure out the number of ways to distribute M distinguishable balls into N distinguishable boxes, each box can at most accommodate V balls and the boxes can be empty.

I did my research and found some related posts. However, I don't understand well why the generating function works for the cases mentioned in the posts. It seems somehow weird for me to introduce an variable z to solve the problem.

In addition, the existing posts discuss the case where only the boxes are distinguishable. This is different from my problem. Does anyone know if there is a known solution for this general problem?

Thank you so much!

1

There are 1 best solutions below

0
On

You can find values by recursion.

Let $f(n_0,n_1,n_2,\ldots,n_V)$ be the number of boxes with $0,1,2,\ldots$ items, where $\sum n_i =N$ and each $n_i \ge 0$

Then $$f(n_0,n_1,n_2,\ldots,n_V) \\= n_0 f(n_0-1,n_1+1,n_2,\ldots,n_V) + n_1 f(n_0,n_1-1,n_2+1,\ldots,n_V) + \\ \ldots + n_{V-1}f(n_0,n_1,n_2,\ldots,n_{V-1}-1,n_V+1)$$

starting with $f(N,0,0,\ldots,0)=1$ and $f(n_0,0,0,\ldots,0)=0$ for $n_0\not =N$. You want those cases representing $M$ balls, i.e. $$\sum\limits_{\sum\limits _j j\, n_j = M} f(n_0,n_1,n_2,\ldots,n_V)$$

For $V=2$, this gives the values in OEIS A089975, which gives various formulae and a link to a related paper