0

This is a self-answer question that was inspired by this recently posted question.

$\underline{\text{The Question}}$
Assuming that balls of the same color are indistinguishable, in how many ways can we distribute $~B~$ white and $~B~$ black balls into $~U~$ distinguishable urns so that each urn has at least 1 ball?

See my answer.

user2661923
  • 35,619
  • 3
  • 17
  • 39

1 Answers1

1

Corrected a typo. In the computation of $~f(n),~$ the first factor should be $~\displaystyle \binom{U}{n},~$ rather than $~\displaystyle \binom{B}{n}.~$


There may be a more elegant way of attacking this problem than the one that I will use. I considered inclusion-exclusion, but found it to be messy. So, I had to settle for the direct approach, which yields a computation that (unfortunately) I am only able to express as a summation.

$\underline{\text{Preliminary Result}}$
PR-1
For $~r \in \Bbb{Z_{\geq 0}}, ~s,t \in \Bbb{Z^+},~$ such that $~r \leq s \leq t,~$
the number of solutions to :

  • $x_1 + x_2 + \cdots + x_s = t,$

  • $x_1, x_2, \cdots, x_s \in \Bbb{Z_{\geq 0}},$

  • For $~r > 0, ~x_1, x_2, \cdots, x_r \in \Bbb{Z^+},$

is $~\displaystyle \binom{[t - r] + [s - 1]}{s-1}.~$

Proof
Employ the change of variables $~y_i = x_i - 1 ~: ~1 \leq i \leq r~$ and
$~y_i = x_i ~: ~i > r.$

Then, there is a bijection between the set of solutions to the above enumeration problem, and the set of solutions to the following enumeration problem:

  • $y_1 + y_2 + \cdots + y_s = t - r,$

  • $y_1, y_2, \cdots, y_s \in \Bbb{Z_{\geq 0}}.$

From Stars and Bars theory, which is also discussed here, the number of solutions to the enumeration problem directly above is $~\displaystyle \binom{[t - r] + [s - 1]}{s-1}.~$


If $~U > 2B~$ then it is impossible for the $~2B~$ balls to leave all $~U~$ urns not empty. Therefore, without loss of generality, $~U \leq 2B.~$

For $~n \in \Bbb{Z^+}, ~n \leq \min(B,U), ~n \geq (U - B),$
let $~f(n)~$ denote the number of ways that $~B~$ white balls can be distributed among exactly $~n~$ urns, such that each urn receives at least one white ball. This implies that once the $~n~$ urns are selected, that none of the other $~(U-n)~$ urns receive a white ball.

Note
This specification for $~n~$ does not permit $~n = 0,~$ which is consistent with the fact that the $~B~$ white balls must go somewhere.

The $~n \geq (U - B)~$ constraint implies that $~B \geq (U - n)~$ which is required to ensure that there are sufficient black balls to cover the other $~(U - n)~$ urns.

Assuming that exactly $~n~$ urns have received the $~B~$ white balls, with each of the $~n~$ urns receiving at least one white ball,
let $~g(n)~$ denote the number of ways that the $~B~$ black balls can be distributed so that each of the remaining $~(U - n)~$ urns receive at least one black ball each. Then, the desired computation for the posted question will be

$$\sum_{n \geq \max[(U - B),1], \,n \leq \min(B,U)} [ ~f(n) \times g(n) ~]. \tag1 $$

Note
The formula in (1) above (also) works when $~U < B,~$ since in that event, $~n~$ will range from $~1~$ through $~U,~$ inclusive.

So, the problem has been reduced to computing $~f(n)~$ and $~g(n).~$


To compute $~f(n),~$ invoke PR-1, with $~\displaystyle n = r, \,n = s, \,B = t \,\implies $

$$f(n) = \displaystyle \binom{\color{red}{U}}{n} \times \binom{B-1}{n-1}. \tag2 $$

Edit
In (2) above a typo was corrected, with the correction shown in $~\color{red}{\text{red}}.$

In (2) above, the first factor on the RHS represents the number of ways of selecting the $~n~$ urns that will be non-empty.

To compute $~g(n),~$ invoke PR-1, with $~\displaystyle U - n = r, \,U = s, \,B = t \,\implies $

$$g(n) = \binom{B - [U - n] + [U-1]}{U - 1} = \binom{B + n - 1}{U - 1}. \tag3 $$

The formula for $~g(n)~$ in (3) above takes some explaining.

Assume that exactly $~n~$ urns will each contain at least one white ball, and that none of the other $~(U - n)~$ urns (if any) will contain any white balls. Assume further that the pertinent $~n~$ urns have been identified, which corresponds to the use of the $~\displaystyle \binom{U}{n}~$ factor in (2) above.

Then, with respect to the computation of $~g(n),~$ it is irrelevant how many white balls are in each of these $~n~$ urns. The only thing that counts is that each of the other $~(U - n)~$ urns, which may also be regarded as having been identified, receive at least one black ball each.

In summary, the final computation is

$$\sum_{n \geq \max[(U - B),1], \,n \leq \min(B,U)} \binom{U}{n} \times \binom{B-1}{n-1} \times \binom{B + n - 1}{U - 1}. \tag4 $$


$\underline{\text{Addendum}}$

Suppose that you are considering the more general problem of there being exactly $~K~$ colors (instead of only $~2~$ colors), with exactly $~B~$ balls of each color. Here, it is assumed that you are again required to find the number of different ways of distributing the $~(K \times B)~$ balls so that none of the $~U~$ urns are empty.

Also assume (perhaps wrongly), that I have not made an arithmetic or analytical mistake, which implies that the formula in (4) above is accurate when $~K = 2.$ Further assume that my exact same method is employed in the more general $~K~$ color problem. Then, the computation will require a nested summation that is $~(K-1)~$ levels deep.

It will be interesting to see if another MathSE reviewer can find a more elegant expression that answers the problem when $~K = 2.~$ Alternatively, it will be interesting to see if another MathSE reviewer can find some (moderately) more elegant computation in the more general $~K~$ color problem, perhaps involving inclusion-exclusion.

One obvious improvement try is to assume that the first $~(K-1)~$ colors collectively leave exactly $~[ ~(BK) - c ~]~$ urns empty, where $~[ ~(BK) - c ~] \leq B.~$ So, your analysis would (seem to) parallel the analysis in my answer, and result in a 1-level deep summation, with $~c~$ used instead of $~n.~$

The difficulty with that approach is that it drastically under-counts the distinct distributions. For example, assume that $~K = 7, ~B \geq 10,~$ and consider any specific solution that has the first urn receiving exactly $~10~$ balls.

The number of distinct ways that this can be done is represented by the number of solutions to

  • $~x_1 + x_2 + \cdots + x_6 = 10,~$

  • $~x_1, x_2, \cdots x_6 \in \Bbb{Z_{\geq 0}}~$

By Stars and Bars theory, there are $~\displaystyle \binom{10 + [6-1]}{6-1} = \binom{15}{5}~$ distinct ways, instead of only $~1~$ way. Further, there are two other complications:

  • Not only must the number of distinct ways for each urn be found, based on the total number of balls in that urn of the first $~(K - 1)~$ colors, but each distinct way will place different constraints on the number of balls of Color-$M ~: ~M \in \{1,2,\cdots,K-1\},~$ that remain available for use.

    This implies that you can not perform the computations for each urn separately, but must consider the computation for each urn in light of the number of balls of Color-$M~$ that have been used in the previous urns.

  • Similar to the first bullet point directly above, suppose that $~B < 10.~$ Then, a third constraint must be added to the exploration of the number of solutions associated with Urn-1: $~x_1, x_2, \cdots, x_6 \leq B.~$ Basic Stars and Bars problems with an upper bound on each variable are discussed here.

user2661923
  • 35,619
  • 3
  • 17
  • 39
  • Pls correct me if I am wrong so for my question 6 white 6 black balls and 10 urns , n≥4 and n≤6 , so putting it in your summation , I got 505 as the answer which is much less than actual answer 26250 , so is there arrangement not counted ? – Guess Mar 27 '24 at 06:24
  • @Guess Good catch. See the very first line in my (now edited) answer. I have corrected a typo. The correct computation is $$\sum_{n \geq \max[(U - B),1], ,n \leq \min(B,U)} \binom{U}{n} \times \binom{B-1}{n-1} \times \binom{B + n - 1}{U - 1}.$$ For $~(B,U) = (6,10),~$ this computes to $$\sum_{n=4}^6 \binom{10}{n} \times \binom{5}{n-1} \times \binom{5+n}{9} = 26250.$$ – user2661923 Mar 27 '24 at 12:26