0

"I want to choose m elements from a set of n numbers, where some elements may appear multiple times. How can I calculate the number of possible selections?

For example, if the set of numbers is given as {1,2,2,3}, I can choose three numbers in 3 possible ways: {1,2,3}, {1,2,2}, or {2,2,3} (I understand the probabilities are different). How can I calculate the number of combinations if I know which elements are repeated and how many times?"

  • 1
    Isn't this the same case as the study of anagrams? – Bruno Dec 09 '24 at 12:29
  • @Bruno It is not the same as counting anagrams because the order in which the elements are selected does not matter. – N. F. Taussig Dec 09 '24 at 12:52
  • I don't understand the premise. What does "if I know which elements are repeated and how many times" mean? In your example, are you saying "we know that $2$ is repeated twice" or "we know that no number is repeated" or something else entirely? – lulu Dec 09 '24 at 13:03
  • If you are saying that "specifying a 'combination' means specifying the multiplicity with which each of the numbers appears, with no regard to order" then this is the problem of Constrained Stars and Bars for which no simple closed formula is available. – lulu Dec 09 '24 at 13:13
  • @lulu My apologies for the unclear wording. We know the entire given set, including each element and how many times each element is repeated. For example, in a set of four numbers, we know that 1 and 3 are each included once, while 2 is included twice. If all the elements were different it would be simply C(m,k) but the problem is repeated elements of the set. I will look into link you provided thanks. – double_N Dec 10 '24 at 04:13

1 Answers1

0

This is the kind of problem that first introduced me to generating functions back in the days. If you have $n_1$ objects of type $1$, $n_2$ objects of type $2$, and so on, all the way to $n_k$ objects of type $k$, the number of ways to select $m$ objects (where order doesn’t matter and objects of the same type are indistinguishable) is $$[x^m]\prod_{i=1}^k(1+x+x^2+\cdots+x^{n_i})=[x^m]\prod_{i=1}^k\frac{1-x^{n_i+1}}{1-x},$$ where $[x^m]$ means the coefficient of $x^m$. In your example, $k=3$, $n_1=1$, $n_2=2$, $n_3=1$, $m=3$, giving $$[x^3](1+x)(1+x+x^2)(1+x)=3.$$ Basically the power you pick in every factor is the number of objects of that type that are going to be in the selection.