0

We have $n_i$ identical objects of type $i$, for $i = 1,...m$. Let n be less or equal to $n_1 + n_2 +...+ n_m$. How many sequences of length n (order matters) we can construct using these objects? Is there a formula or a recursive relation. Remark. The question is motivated by the well known elementary problem. How many three digit numbers we can write using 3 digits 1, two digits 2, and 4 digits 3?

3 Answers3

1

If $n=n_1+n_2+...+n_m$, it's the familiar formula ${n!}\over{n_1!n_2!.....n_m!}$,$\quad{9!}\quad\over{3!2!3!}$ for the given example

But continuing with the given example, $n=9, m = 3$,
we want all distinct $3$ digit numbers from $111223333$

One way is to break up into cases:

Three of a kind, e.g. 111: $\binom21\frac{3!}{3!} = 2$

Two-one of a kind, e.g. 112: $\binom31\binom21\frac{3!}{2!1!} = 18$

One-one-one of a kind, e.g. 123: $\binom33\frac{3!}{1!1!1!} = 6,\;\; \boxed{total =26}$

But this becomes tedious and error prone for larger problems which can instead be formulated as finding the coefficient of $x^3\; in\;\; 3!(1+x+\frac{x^2}{2!} +\frac{x^3}{3!})(1+x+\frac{x^2}{2!})(1+x+\frac{x^2}{2!} +\frac{x^3}{3!} +\frac{x^4}{4!})$

The indices of $x$ in each term represent the number of times you have taken that class of object,
e.g. if you took two $1's$ and one $3$, it would be $3!\cdot\frac{x^2}{2!}\cdot x = \frac{3!}{2!}x^3$,
and you would be adding up all possible permutations of $3$ in this way.

0

If you use all your objects, i.e. $n = n_1 + \cdots + n_m$, then the number of arrangements is given by the multinomial coefficient ${n \choose n_1 \cdots n_m}$. If you use less, then you have to sum over all choices that make up $n$, and the number of arrangements is $$ \sum_{(k_1 \leq n_1), \cdots , (k_m \leq n_m) ; n = k_1 + \cdots + k_m} {n \choose k_1 \cdots k_m} $$

An extreme example case would be if you just have a sequence of length $n=1$. Then there are $m$ choices allowed for by the sum, which can be indicated {$k_1 = 1$,$k_2 = 0$,$\cdots$ ,$k_m = 0$} , $\cdots$ , {$k_1 = 0$,$\cdots$ ,$k_{m-1} = 0$,$k_m = 1$}, and the sum gives $$ \sum_{\left\{k_1 = 1,k_2 = 0,\cdots ,k_m = 0\right\} , \cdots , {\{k_1 = 0,\cdots ,k_{m-1} = 0,k_m = 1\}}} {1 \choose 0, \cdots, 0, 1} \\ = \sum_{\left\{k_1 = 1,k_2 = 0,\cdots ,k_m = 0\right\} , \cdots , {\{k_1 = 0,\cdots ,k_{m-1} = 0,k_m = 1\}}} 1 \\ = m $$ which was clear.

Andreas
  • 15,175
0

A recursive solution can be obtained by summing up the sequences ending with an object that belongs to each one of the $m$ classes. This gives

$$S^{(n)}_{n_1,n_2 \cdots n_m}= T^{(n-1)}_{n_1-1,n_2 \cdots n_m} +T^{(n-1)}_{n_1,n_2 -1, \cdots n_m}+\cdots + T^{(n-1)}_{n_1,n_2 , \cdots n_m-1}$$

where

$$ T^{(n-1)}_{n_1,n_2 \cdots, n_i-1, \cdots n_m} =\begin{cases} 0 & \text{if } n_i =0 \\ 1 & \text{if } n_i >0 \text{ and } n=1\\ S^{(n-1)}_{n_1,n_2 \cdots, n_i-1, \cdots n_m} & \text{elsewhere} \end{cases} $$

For example : http://ideone.com/8QScl5

leonbloy
  • 63,430