3

I will use letters as objects. In general, suppose we have objects $\underbrace{X_1, \dotsc, X_1}_{n_1}, \underbrace{X_2, \dotsc, X_2}_{n_2}, \dotsc,\dotsc, \dotsc, \underbrace{X_k, \dotsc, X_k}_{n_k}$. Then what is the number of ways we can choose and order $N$ objects $0 \leq N \leq n_1 +\dotsb + n_k$, i.e. the number of permutations? If $n_1 = \dotsb = n_k = 1$, then of course this is just a standard permutation problem. I am just curious if there is a formula for it.

Note: I initially asked about combinations, which was pointed out to be a duplicate of the question here. I have deleted the original post to ask this question, instead.

  • does a recurrence help you? – ILikeMath Aug 09 '13 at 19:51
  • Sorry for the confusion, Pratyush. I meant you should link to the question of which your original was a duplicate. A link to a deleted question won't stay active for long. – Cameron Buie Aug 09 '13 at 19:56
  • @DiegoHuerfano Of course a explicit formula is better but I would like to see your recurrence solution. – Pratyush Sarkar Aug 09 '13 at 20:02
  • "If $n_1 = \cdots n_k=1$, then of course this is just a standard permutation problem" ... only if $k=N$, no? – leonbloy Aug 09 '13 at 20:16
  • @leonbloy If $n_1 = \dotsb = n_k = 1$, then the total number of objects is $n_1 + \dotsb + n_k = 1 + \dotsb + 1 = k$ and I am choosing and ordering $N$ objects so the answer is ${}^kP_N = \frac{k!}{(k - N)!}$. For the even more special case $k = N$, its ${}^kP_k = k!$. – Pratyush Sarkar Aug 09 '13 at 20:51
  • Since both the answers given are pretty much the same, I'll leave for a while to see if there are any other answers before I choose best answer. – Pratyush Sarkar Aug 10 '13 at 01:00

2 Answers2

3

Let $m_i$ be the number of objects of type $i$ that were picked. Then $0\le m_i \le n_i$ and $\sum_{i=1}^k m_i = N$. For a given set $\{m_i\}$, there are $ N!/\prod (m_i!)$ permutations. Hence the count is given by

$$ \sum_{ m_1,m2 \cdots m_k } \frac{N!}{\prod m_i!} $$

Where the sum is restricted to $0\le m_i \le n_i$ and $\sum m_i=N$. That is:

$$ N ! \sum_{m_1=0}^{\min(N,n_1)} \frac{1}{m_1!} \sum_{m_2=0}^{\min(N-m_1,n_2)} \frac{1}{m_2!} \cdots \sum_{m_{k-1}=0}^{\min(N-m_1-m_2-\cdots,n_{k-1})} \frac{1}{m_{k-1}!} \frac{[N-(m_1+m_2 + \cdots +m_{k-1})\le n_k]}{(N-(m_1+m_2 + \cdots +m_{k-1}))!} $$

leonbloy
  • 63,430
  • But for each $m_i$ elements, we can choose them of $\binom{n_i}{m_i}$ ways!. – ILikeMath Aug 09 '13 at 21:10
  • mmm, no, I don't read the problem in that way, I consider the elements inside each set as undistinguishable. Say, if $n_1=5$ and I choose $m_1=3$, there are not ${5 \choose 3}$ ways of picking those 3, there is only one way. $n_1=5$ just gives me a bound on $m_1$. Of course, this is a matter of interpretation. – leonbloy Aug 09 '13 at 21:14
  • leonbloy is right. What I intended was for any $i$, $X_i, \dots, X_i$ are identical. – Pratyush Sarkar Aug 09 '13 at 21:16
  • @leonbloy If I were to find the solution in a straight forward way, your answer is the same thing I would do also but the problem is $\sum_{ m_1,m2 \cdots m_k } \frac{N!}{\prod m_i!}$ is very hard to calculate. – Pratyush Sarkar Aug 09 '13 at 21:19
  • Yes, they are identical, but I think that, for example, if we have $2$ undistinguishable objects we can choose one of them of $2$ ways no of $1$ way. – ILikeMath Aug 09 '13 at 21:19
  • "is very hard to calculate" Of course, this is not a nice solution. Perhaps it's not even worthy of being call a "solution" :-). But it is not hard to calculate... numerically. – leonbloy Aug 09 '13 at 21:21
  • @PratyushSarkar am I right? or in my example there is $1$ way of choose them? – ILikeMath Aug 09 '13 at 21:28
  • @DiegoHuerfano I guess the problem is whether we want to choose $N$ objects first (In which case you are right. But some permutations are counted multiple times because of that) or simply look for all permutations of length $N$ (Then no permutation of length $N$ is counted more than once). So we can interpret my original question in both ways I guess. But I think its better not to count permutations more than once. So lets say there is just one way of choosing from identical objects. – Pratyush Sarkar Aug 09 '13 at 21:31
  • Ok, i get it. I edited my answer according that. – ILikeMath Aug 09 '13 at 21:37
  • @leonbloy I don't really understand how you got the last equation. Can you explain it a little more? – Pratyush Sarkar Aug 09 '13 at 21:44
  • It looks pretty straightforward to me (unless I messed up something), it's the standard multiple summation way (analogous to multidimensional integrals), each sum consider the "outer" ones as fixed... – leonbloy Aug 10 '13 at 00:26
  • @leonbloy Yeah, I get it now. I was just unsure about the upper limits of the sum, but I got it. One thing though. I think the last summation term should be $\frac{1}{(N - m_1 - m_2 - \dotsb - m_{k - 1})!}$ instead because you don't have any choice over how many to choose in the last group (you have to choose enough to make the total $N$). – Pratyush Sarkar Aug 10 '13 at 00:57
  • You're right! And we need to add an indicator function to remove the terms that violate the $m_k\le n_k$ condition... – leonbloy Aug 10 '13 at 02:02
  • what is the index on the $\prod$? – Tommy May 16 '17 at 19:24
0

Consider the recurrence where $n$ is the number of elements to choose, $k$ is the class that we are considering and $f(n,k)$ means the number of ways of take $n$ elements with elements of the classes $1,2,...,k$

$$f(n,k)=\sum\limits_{i=0}^{min(n,n_{k})}{ \frac{1}{i!} f(n-i,k-1)}, \space\space\space\space k>0$$ $$f(0,0)=1$$ $$f(n,0)=0,\space\space\space\space n>0.$$

We know that if we have $n$ letters and there are $k$ subclasses where each class have $n_j$ letters $L_j$ with $n_1+...+n_k=n$, then the number of all possible permutations is

$$\frac{n!}{n_1!...n_k!} \space\space\space\space(1)$$

because each $n_j$ letters $L_j$ are indistinguishable.

Now there are $n_1+...+n_k$ letters in total and first we want to choose $n$ of them without permute them, then for each class $k$ we will take $i=0$, or $i=1$,..., or $i=n_k$. So we will add up each election which yields to $f(n,k)=\sum\limits_{i=0}^{min(n,n_{k})}{ f(n-i,k-1)}$. But we want to choose them permute them, so will use the formula $(1)$ and we obtain the above recurrence. Therefore the answer will be

$$N!f(N,k).$$

ILikeMath
  • 1,514
  • I don't quite understand what is $f(n,k)=\sum\limits_{i=0}^{min(n,n_{k})}{ f(n-i,k-1)}$ and how you got it in the last paragraph. – Pratyush Sarkar Aug 09 '13 at 21:42
  • I think I get that equation now. But now I am not sure about the upper limit $min(n,n_{k})$ of that sum. – Pratyush Sarkar Aug 09 '13 at 21:51
  • If we are in the class $k$, we can choose $0$ elements of them, or $1$, .... So we will add up those "elections". Whenever we choose an element of the class $k$, we substract to the total elements for choose $n$ so we have $f(n,k)=f(n-0,k-1)+f(n-1,k-1)+...$. The $k-1$, if we already choose a number of elements in class $k$, we need to choose elements in the next stage ($k-1$ class). The $min(n,n_k)$ is to fix a limit, beacuse in the stage $k$ we can not choose a number of elements more than $n_k$, but we can not choose a number of elements more than $n$ (the remain). – ILikeMath Aug 09 '13 at 21:54
  • Thanks. I get it now. But now I don't understand the $\frac{1}{i!}$ factor hehe. I don't think it is needed because nothing is counted more than once. – Pratyush Sarkar Aug 09 '13 at 22:15
  • I don't think so. If we quit $\frac{1}{i!}$ factor, then the answer $N!f(N,k)$ will count more than we need. So, if we put that factor, we are using the formula $(1)$ with $\frac{N!}{i_1!...i_k!}$. – ILikeMath Aug 09 '13 at 22:20
  • But $N!$ does count a permutation more than once. But does $\sum\limits_{i=0}^{min(n,n_{k})}{ f(n-i,k-1)}$ count more than once? For example lets say $i = 2$. Then we just have $f(n - i, k - 1)$ right? Do we have to divide it by $2$? $f$ is just counting the permutations from the remaining groups of objects (which has nothing to do with the $2$ objects already chosen from the first group), so I don't think it is counting it twice. Am I wrong? – Pratyush Sarkar Aug 09 '13 at 22:27
  • No, with $\sum\limits_{i=0}^{min(n,n_k)}{f(n-i,k-1)}$ then $f(N,k)$ only counts the number of ways of choose $i_1,...,i_k$ such that $i_1+...+i_n=N$ where $i_j$ for $j \in {1,...,k}$ is the number of elements that we choose of the class $k$ without permute them. For example the elements AABBB we have $n_1=2$ and $n_2=3$, with $f$ without factor $\frac{1}{i!}$ we will count the elections with $N=3$: BBB, ABB, AAB. But for each one of theese three elections we need permute them, and with the formula (1) will be our answer. So the total elections count for my recurrence will be – ILikeMath Aug 09 '13 at 22:37
  • BBB, ABB, BAB, BBA, AAB, ABA, BAA which yields to $7$, that is the answer. – ILikeMath Aug 09 '13 at 22:38
  • I understand it perfectly now. Thanks for all your help. I also noticed that if you keep using the recursion, you get the last equation in leonbloy's answer (well almost). – Pratyush Sarkar Aug 10 '13 at 00:52