1

I asked another related question, but have not got any answer. So, I decided to break the question down into more simple questions. Here, you may see the main question.

Assume that there are $m$ boxes each of which contains $n$ compartments. There are also $l$ balls, where $\ m\ < \ l\ <\ (m-1)n+2$. Moreover, the balls are the same.

$\bullet$ I would like to know how many ways there are to place the $l$ balls into the $m$ boxes such that

$1-$ Each compartment can hold up to one ball.

$2-$ Each box must have at least one ball.

The probable solutions:

(a) If I first put a ball in each box, and then place the rest arbitrary through the compartments, the constraints will be satisfied. In this way, we first need to select a compartment of each box to put a ball. There are $\binom n1 ^m$ ways to do so. Then, to place the other balls arbitrary into the available compartments, there are $\binom{mn-m}{l-m}$ ways.

As a result, the answer will be $$C_1(m,n,l)\ =\ \binom n1 ^m \times \binom{mn-m}{l-m}$$

(b) Another answer may consider as $$C_2(m,n,l)\ =\ \sum_{i=0}^{k}(-1)^i \binom{m}{i}\binom{(m-i)n}{l}, $$ where $k = m - \lceil l/n\rceil $.

In this summation, the first term ($i=0$) counts the number of ways to place $l$ balls in $mn$ compartments with no constraint. The second term removes the cases that at least one of the boxes are empty. But, the second term, remove the cases with two empty boxes two times! So, in the third term, we add once such cases, and so forth.

$\bullet$ According to a simple example with $m=2,\ n=3,\ l=3$, we see that the answers are different. For this example, we have

$$C_1(2, 3, 3) = 3^2\times \binom 41 = 36,$$

$$C_2(2, 3, 3) = \binom 63 - \binom 21 \binom 33 = 20-2=18.$$

Please let me know your answers or at least your idea on the given answers. Why are they different?

Majid
  • 3,401
  • 1
    if each box has to have at least one ball, then the problem is reduced to l-m balls, m boxes, n - 1 compartments per box. And from there, the same as the problem with no conditions. – Cato Jan 17 '17 at 13:05
  • Seems to understand that, in each single box, you distinguish the different ways in which the $n$ compartments are occupied: is that so? can you provide a simple example (e.g. with $l=3,m=2,n=3$)? – G Cab Jan 17 '17 at 13:41
  • @Cato , According to your way, we have $\left ( \binom n1 \right )^m$ cases to place the first $m$ balls in the boxes, and for each one we have $\binom{m(n-1)}{l-m}$ cases. So, the final answer is $\left ( \binom n1 \right )^m \times \binom{m(n-1)}{l-m}$ . Is it the same as my answer? – Majid Jan 17 '17 at 14:01
  • are the balls distinguished ? – G Cab Jan 17 '17 at 14:04
  • @GCab I will add some more explanations to the question according to your comment and the one from Cato. – Majid Jan 17 '17 at 14:04
  • yes, I think it is much needed ! – G Cab Jan 17 '17 at 14:05
  • @GCab I have now added some more explanations. Please let me know your idea. – Majid Jan 17 '17 at 14:30
  • @majid - I don't know how to solve the problem, but I was pointing out that since there is one way to place one ball in each box, that can be taken as a starting point with adjusted parameters. I'm treating the balls as indistinguishable. – Cato Jan 17 '17 at 14:33
  • it seems to me that calculating how many boxes can be full is important. If you had a case where only one box could be filled, then the remaining balls are distributed over the remaining boxes, but you have to consider all of the combinations of filled boxes – Cato Jan 17 '17 at 14:39
  • @Cato Actually, the balls are the same. About the number of boxes which can be full, I did not get your point. I treated all the compartments similarly without considering that from which box are. – Majid Jan 17 '17 at 15:29
  • I think I see it: with 2 boxes, 3 compartments per box and 3 balls - you have 3 x 3 = 9 ways to put 1 ball in each box, then 4 compartments for the last ball, so it is 4x9 = 36 - but that makes the compartment you put the ball into relevant – Cato Jan 17 '17 at 16:22
  • in your question you say 'I would like to know how many ways there are to place the l balls into the m boxes such that...' That seems to imply that the compartment you put the ball into does not matter, i.e. 1 ball in box 1 is 1 combination, whichever compartment it is in – Cato Jan 17 '17 at 16:25
  • if this is an academic question that has been posed, then I imagine the answer they want is the number of ways you can put the balls in the boxes (ignoring which compartment) however if it is your own problem then the formula that gives 36 seems correct – Cato Jan 17 '17 at 16:28
  • The way the question has developed - there are $n^m$ ways of making the initial set up of 1 ball in each of the m boxes, then the remaining $l - m$ balls are arranged in the remaining $(n-1)m$ spaces - so multiply the two terms together - so yes I agree with your answer, assuming your assumptions – Cato Jan 17 '17 at 16:33
  • Ok, it seems that I got the terms of your question: working on it. – G Cab Jan 17 '17 at 16:41
  • @Cato This is my own question. If you might see, I presented two different answers. I do not know what is wrong with which one! On the simple example, you see they lead to different answers. – Majid Jan 17 '17 at 16:58
  • @GCab Thanks. I appreciate your taking time to work on it. – Majid Jan 17 '17 at 17:36

2 Answers2

2

To fix the context, let us clear that we are looking for the number of ways to arrange
- $l$ undistinguishable balls
- into $m$ distinguishable boxes, each provided with $n$ distinguishable compartments
- counting only the arrangements that contain no empty boxes.

As a visual help, let us reproduce an example with $m=2, \, n=3, \, l=3$.

Bin_Compart

Obviously, the total number of ways to put the $l=3$ undistinguishable balls (the "ones")
into the $m \cdot n = 6$ distinguishable places is $$ T(m,n,l) = \left( \begin{gathered} m\,n \\ l \\ \end{gathered} \right) = 20 $$ and deducting the first and last row, in which at least a box is totally empty, we get $18$ dispositions leaving no empty box, as correctly returned by the $C(m,n,l)$ formula.

That premised, there are various combinatorical and algebraic considerations to deduce, which renders this argument very interesting. I'll try and concisely expose the main ones.

In the formula for $C(m,n,l)$ the limits on the summation index $i$ may algebraically be omitted, as they are intrinsic in the two binomials when defined as $$ \left( \begin{gathered} x \\ q \\ \end{gathered} \right) = \left\{ {\begin{array}{*{20}c} {x^{\,\underline {\,q\,} } /q!} & {\left| {\;0 \leqslant \text{integer}\,q} \right.} \\ \text{0} & {\left| {\;\text{otherwise}} \right.} \\ \end{array} } \right. $$ which leaves more freedom in operating on the formula, while for computational purposes we can fix them to $0 \leqslant i \leqslant m$. So we have better write:

$$ C(m,n,l)\quad \left| {\;0 \leqslant \text{integer}\;m,n,l} \right.\quad = \sum\limits_{\left( {0\, \leqslant } \right)\;i\,\,\left( { \leqslant \,m} \right)} {\left( { - 1} \right)^{\,i} \left( \begin{gathered} m \\ i \\ \end{gathered} \right)\left( \begin{gathered} \left( {m - i} \right)n \\ l \\ \end{gathered} \right)} \tag {1} $$

Concerning the approaches in your post, note that the scheme leading to $C_1$ is over-shooting, because it makes distinction between the ones of "first " and "second" introduction within each box, and that is difficult to compensate. The Inclusion/Exclusion scheme is instead correct.

The example sketched indicates that the total number of arrangements can be partitioned into those that contain exactly $0$ empty boxes (${n}\choose {0}$ ways to choose that) and the associated $N(m,n,l)$ rows in the remaining boxes, plus exactly $1$ empty boxes (${n}\choose {1}$ ways) and the associated $N(m-1,n,l)$ rows, ...,
$k$ empty boxes associated to $N(m-k,n,l)$ rows, for $k$ ranging from $0$ to $m$, so that we can write

$$ T(m,n,l) = \left( \begin{gathered} n\,m \\ l \\ \end{gathered} \right) = \sum\limits_{\left( {0\, \leqslant } \right)\;k\,\,\left( { \leqslant \,m} \right)} {\left( \begin{gathered} m \\ k \\ \end{gathered} \right)C(m - k,n,l)} = \sum\limits_{\left( {0\, \leqslant } \right)\;k\,\,\left( { \leqslant \,m} \right)} {\left( \begin{gathered} m \\ k \\ \end{gathered} \right)C(k,n,l)} \tag {2} $$

which is satisfied by (1).
This implicit relation can be inverted, using the binomial inversion theorem, giving

$$ \begin{gathered} C(m,n,l) = \sum\limits_{\left( {0\, \leqslant } \right)\;k\,\,\left( { \leqslant \,m} \right)} {\left( { - 1} \right)^{m - k} \left( \begin{gathered} m \\ k \\ \end{gathered} \right)\left( \begin{gathered} n\,k \\ l \\ \end{gathered} \right)} = \sum\limits_{\left( {0\, \leqslant } \right)\;k\,\,\left( { \leqslant \,m} \right)} {\left( { - 1} \right)^k \left( \begin{gathered} m \\ m - k \\ \end{gathered} \right)\left( \begin{gathered} n\,\left( {m - k} \right) \\ l \\ \end{gathered} \right)} = \hfill \\ = \sum\limits_{\left( {0\, \leqslant } \right)\;k\,\,\left( { \leqslant \,m} \right)} {\left( { - 1} \right)^k \left( \begin{gathered} m \\ k \\ \end{gathered} \right)\left( \begin{gathered} n\,\left( {m - k} \right) \\ l \\ \end{gathered} \right)} \hfill \\ \end{gathered} \tag {3} $$

which provides a further confirmation of the validity of (1).

Referring to the scheme, we can infer an additional recurrence.
Consider to add an empty box aside the others, and move one ball at time from the original block to the new box. Each configuration obtained is a partition of that corresponding to $m+1,n,l$, and the No. of rows is accounted by $C(m,n,l-k) C(1,n,k)$.
The process goes on till the new box is full ($k=n$) or the original block is empty ($k=l$). But we can waive these thresholds, as they are implicit in the product of the two $C$ factors, defined as in 1).

So we can write

$$ C(m + 1,n,l)\quad \left| {\;0 \leqslant \text{integer}\;m,n,l} \right.\quad = \sum\limits_{\left( {0\, \leqslant } \right)\;k\,\,\left( { \leqslant \,l} \right)} {C(m,n,l - k)\;C(1,n,k)} \tag {4} $$

which is a convolutory recurrence and which is satisfied by formula 1).
In fact, considering the layout of the boxes, it is clear that a more general recurrence holds: $$ C(m + q,n,l)\quad \left| {\;0 \leqslant \text{integer}\;m,n,l,q} \right.\quad = \sum\limits_{\left( {0\, \leqslant } \right)\;k\,\,\left( { \leqslant \,l} \right)} {C(m,n,l - k)\;C(q,n,k)} $$

To solve this recurrence autonomously, without recurring to the conjectured formula 1), it remains to fix the initial conditions.
In the case of a single box, by definition $C(1,n,l)$ clearly is:

$$ C(1,n,l)\quad = \quad \begin{array}{*{20}c} {n\backslash l} &| & 0 & {1 \leqslant l} \\ \hline 0 &| & 0 & 0 \\ {1 \leqslant n} &| & 0 & {\left( \begin{gathered} n \\ l \\ \end{gathered} \right)} \\ \end{array} \quad \quad = \quad \left( \begin{gathered} n \\ l \\ \end{gathered} \right) - \left( \begin{gathered} 0 \\ l \\ \end{gathered} \right) $$

then it is easy to check that the recurrence 4) gives as solution formula 1).

Note that in the case of having no box, i.e. $m=0$, formula 1) returns

$$ C(0,n,l)\quad = \quad \begin{array}{*{20}c} {n\backslash l} &| & 0 & {1 \leqslant l} \\ \hline 0 &| & 1 & 0 \\ {1 \leqslant n} &| & 1 & 0 \\ \end{array} \quad \quad = \quad \left( \begin{gathered} 0 \\ l \\ \end{gathered} \right) $$

i.e. that the "empty" box is filled with $0$ balls (which is a usual concept in combinatorics) .
So $C(m,n,l)$ counts the arrangements with no empty box, and in case of keeping the definition of with at least 1 ball per box then $m$ should be limited to be greater than $0$, or amended accordingly.

G Cab
  • 35,964
  • Foremost, Thank you so much! Then, on the Eq. (1), do you agree that the first binomial selects $i$ boxes to keep empty and the second binomial distributes the $l$ balls through the rest $(m-i)n)$ compartments? If so, I believe that $i$ has an upper limit. Actually, the minimum number of required boxes to place all the $l$ balls is $\lceil l/n \rceil$, and so the maximum number of boxes which can be kept empty is $k=m-\lceil l/n \rceil$. Hence, I think $k$ should be considered as the upper bound for $i$ in Eq. (1). Do you agree? – Majid Jan 18 '17 at 11:29
  • In the second equation, Eq. (2), I did not get the second equality. How do you replace $C(m-k, n, l)$ with $C(k, n, l)$? Also, I have some doubts on the first equality. It would be nice if you may add some passages to explain them. – Majid Jan 18 '17 at 12:04
  • And what about the cases that some boxes contains exactly one ball? Please have a look at this question (http://math.stackexchange.com/questions/2101768/how-many-ways-are-there-to-place-l-balls-in-m-boxes-each-of-which-has-n-co), if you may have time. – Majid Jan 18 '17 at 12:09
  • @Majid: 1) combinatorially / physically there is a limit to the summation and it is as you said. But you can imagine to fix it in any case to $m$ and then impose / check that the resulting formula be null for $k < i \leqslant m$, which is fact what the 2nd binomial guarantees when the upper term is positive and lower than $l$, while when it is negative (with $n,m$ non-negative), meaning that $ m < i$, then the 1st binomial will take care to null the whole product. Therefore, while assuring that $n,m, (l)$ be non-negative, algebraically the limit can be removed, and that is important – G Cab Jan 18 '17 at 15:54
  • @Majid: 2) concerning eq. 2). Sorry, summation upper limit should be $m$ instead of $l$, corrected. Added better explanation of how we arrive to 1st identity on eq. 2). For the 2nd identity, that's because $ {{m } \choose {k}} = {{m} \choose {m-k}}$ and you can invert summation order (that's why it is algebraically important that we can get rid of the summation bounds !). – G Cab Jan 18 '17 at 16:11
  • @Majid: 3) I'll have a look at the other post asap. But first let's "completely" asses the present one: it's a very pregnant subject and there are many other considerations / deductions that can be made: it is in fact mathematically similar to this other subject , wherefrom you can take some hints. – G Cab Jan 18 '17 at 16:22
  • @Majid: I added recurrence 4) + initial conditions, thus completing an additional demonstration that ** your answer b) is correct**. – G Cab Jan 20 '17 at 16:18
  • Thanks G Cab. I enjoyed it! – Majid Jan 20 '17 at 18:09
  • @Majid: glad that you appreciated it: wish you will appreciate the answer to your other related post as well! – G Cab Jan 23 '17 at 21:35
1

I don't know if this should be just a comment or an answer but anyways.

The first method leads to over counting because you count certain cases multiple times.

Example - You have 3 balls $B_1,B_2$ and $B_3$.

Say, you put $B_1$ in $C_1$ and $B_2$ in $C_2$ initially i.e. in the first step and then assigned $B_3$ to $C_2$ and in the other case $B_3$ in $C_2$ initially and then assigned $B_2$ to $C_2$.

The first method will count this twice whereas it is just one case.

The idea for the second method seems absolutely fine.

  • Thanks! It was helpful. And, what is your idea on the second question here (http://math.stackexchange.com/questions/2101768/how-many-ways-are-there-to-place-l-balls-in-m-boxes-each-of-which-has-n-co)? – Majid Jan 17 '17 at 17:12