0

I see this question in various formulations so trying to get a general answer:

Let there be $m$ distinct balls (say, of different colors) with $n_i$ number of balls of each type $i$. Let $n=\sum n_i$.

What is the number of ways of selecting $k$ balls?

I want to focus on the part where $k\le m$ and $\min {\{n_1, n_2, \dots,n_m\}}<k< \max{\{n_1, n_2, \dots,n_m\}}$. So that all other cases will be subset of possibilities from this case (right? I think so because now the selection can have $1$ to $k$ distinct balls).

I could get this much:

WLOG let $n_1<n_2<\dots<n_m$. Let $j>0$ be such that, $n_{j+1} \ge k > n_j$.

  • So, for selecting $k$ distinct balls, there are ${m}\choose{k}$ ways.
  • For $k-1$, two cases: (1) $n_1>1 $, (2) $n_1=1$.
    • For (1), it should be ${m\choose{k-1}}(k-1)$.
    • For (2), it should be ${m-1\choose k-1}(k-1)+{m-1 \choose k-2}(k-2)$

And so on.

How, if possible, can this be generalized?

Dayne
  • 129
  • When you say how many ways, you just mean how many different color combinations, right? To put it another way, you want the number of solutions, in integers, to $$k_1+k_2+\cdots+k_m=k$$ subject to the conditions $0\leq k_i\leq n_i$ where $k_i$ is the number of balls of color $i$ for $1\leq i\leq m.$ Have I understood you correctly? – saulspatz Jul 16 '21 at 03:48
  • @saulspatz: that's smart way to put it. Thanks for this. I will try to solve with this method as well. Meanwhile, if you already know the answer please post. – Dayne Jul 16 '21 at 04:05

1 Answers1

0

I don't think there's a convenient formula for this in full generality. One way to do it this:

The number of solutions in integers to the equation $$k_1+k_2+\cdots+k_m=k$$ subject to $k_1+k_2+\cdots+k_m=k,\ i=1,2,\dots,m$ is the coefficient of $x^k$ in $$(1+x+x^2+\cdots+x^{n_1})(1+x+x^2+\cdots+x^{n_2})\cdots(1+x+x^2+\cdots+x^{n_m})$$

Think about how you go about expanding the polynomial, and I'm sure you'll see why this is the case.

For special cases, such as when all the $n_i$ are equal, you can get a formula. For example, suppose $m=7,\ k=15,$ and each $n_i=3$. Then we want the coefficient of $x^{15}$ in $$\begin{align} (1+x+x^2+x^3)^7&=\left(\frac{1-x^4}{1-x}\right)^7\\ &=(1-x^4)^7(1-x)^{-7}\\ &=\sum_{k=0}^7(-1)^k\binom7kx^{4k}\sum_{k=0}^\infty(-1)^k\binom{-7}kx^k\\ &=\sum_{k=0}^7(-1)^k\binom7kx^{4k}\sum_{k=0}^\infty\binom{k+6}{6}x^k \end{align}$$

Now we just have to pick out the terms that contribute to the coefficient of $x^{15}$. I get $$\binom70\binom{21}6-\binom71\binom{17}6+\binom72\binom{13}{6}-\binom73\binom96$$

If I had to do a problem like the one you described, I'd do it with a computer algebra system.

saulspatz
  • 53,131