Number of ways of selecting N items with K types where each type must have $n_i$ items where $\sum_i n_i = N$

combinatorics

So let's suppose we have $N$ items. We have $K$ types of item.

For each type of item we denote the number of that type of item as $n_i$ and for completeness $(1 <= i <= K)$ with the constraint that

$\sum_i n_i = N$

How many combinations are there of this?

So the simplest case is where $K =1$ where clearly the number of combinations is $1$.

With $K=2$, you take $N\choose{n_1}$ or $N\choose{n_2}$ because the number of combinations of $n_1$ items in N items is the same as the number of combinations of $N-n_1$ items in $N$ items.

However, I come across a problem when I get to $K>2$. I don't know what to make of it at all and find myself very stuck at this. With $K=3$, $N=3$ and $n_i = 1 ,~\forall n_i$ then we end up with, if we label our types of item A, B and C

ABC, ACB, BAC, BCA, CAB, CBA

Now from this I observe that for A, I placed it in a set position, of which there are N positions and then went through the combinations of the rest of it which comes out as

${{N}\choose{n_1}} {{N-1}\choose{n_2}} = 3\times 2 = 6$ combinations

Now doing the same again but with $K=3$, $N=4$, $n_1 = 2$, $n_2 = 1$, $n_3 =1$ we get

AABC
AACB
ACBA
ABCA
BCAA
CBAA
BAAC
CAAB
ABAC
ACAB
BACA
CABA

and the way I have done it this time is to place the two A's in set positions and then use the combinations of the others: so

${N\choose{2}} {{N-2}\choose{1}} = 6 \times 2 = 12$ combinations

So can this generalise for say $n_1 = P, ~n_2 = Q, ~n_3 = R$ with $N=P+Q+R$:

${{N}\choose{n_1}}{{N-n_1}\choose{n_2}}{{N-n_1-n_2}\choose{n_3}}$

and does that generalise to $K$ types by:

$\Pi_k{{{N-\sum_{i=0}^{i=k-1}n_i}\choose{n_k}}}$ where $n_0 = 0$?

I'm not really equipped with the skills to prove this, as I did not focus on combinatorics when I did my maths degree I did pure maths and mechanics/fluid mechanics instead, but that's my best effort and I haven't found an answer elsewhere

Thank you for listening

Best Answer

What you have written is correct, but it can be explained in a simpler way. In particular your final formula has an undesirable look.

Assume that the $n_i$ objects of type $T_i$ $(1\leq i\leq K)$ are marked with numbers from $1$ to $n_i$. If we also look at the numbers we can linearly order the totally $N$ objects in $N!$ ways. Now in your counting the numbers do not play a rĂ´le. This means that the $n_i!$ permutations of the objects of type $T_i$ among themselves in such an ordering do not lead to new "combinations", and this for each $i\in[K]$ separately. It follows that your number of "combinations" is given by $${N!\over n_1!\>n_2!\>\ldots\>n_K!}\ ,$$ and this is the way the final formula should be written.

Related Question