[Math] Ways of Distributing $n$ balls among $k$ boxes, each box containing $L \leq x_i \leq M$ or $0$ Balls

combinatoricsinteger-partitions

I need to calculate the number of ways of distributing $n$ balls among $k$ boxes, each box may contain no ball, but if it contains any, then it must contain $\geq L$ & $\leq M$ balls.

This effectively solves:

$x_1+x_2+x_3+\dotsb+x_k = n; \quad x_i\in [0,L,L+1,L+2,\dotsc,M-1,M]$.

Is there a known solution to this? Googling "bounded combinatorics" and similar doesn't reveal anything, except for the post below which is a solution for an upper-bound.

Number of ways to distribute indistinguishable balls into distinguishable boxes of given size

It feels like there should be a solution to the $L \leq x_i \leq M$ case, and then the $0$-possible case can then (hopefully) be added to this as a solution to "ways to distribute $n$ balls among $k$ boxes such that at least one box contains no balls"

Best Answer

Use generating functions to see if something turns up.

Each variable gets represented by: $$ 1 + z^L + z^{L + 1} + \ldots + z^M = 1 + z^L \frac{1 - z^{M - L + 1}}{1 - z} $$ The full problem is then to get the coefficient of $z^n$: $$ [z^n] \left(1 + z^L \frac{1 - z^{M - L + 1}}{1 - z} \right)^k = [z^n] \left(\frac{1 - z + z^L - z^{M + 1}}{1 - z} \right)^k $$ Doable by expanding the numerator using the multinomial theorem, and using that with the extended binomial theorem: $$ (1 + u)^{-m} = \sum_{r \ge 0} \binom{-m}{r} u^r = \sum_{r \ge 0} (-1)^r \binom{r + m - 1}{m - 1} u^r $$ where $m \in \mathbb{N}$, but the coefficients won't turn out nice.

Related Question