0

If we have a multiset S = {a,a,b,b,b,c,d}

How to calculate all possible combinations if we take r items at a time?

For example if r = 3 then the combinations will be:

a,a,b
a,a,c
a,a,d
b,b,b
b,b,a
b,b,c
b,b,d
a,b,c
a,b,d
a,c,d
b,c,d

The only thing I know is that the last four of the combinations are taken from the combinations of distinct elements {a,b,c,d} taken 3 at a time.

Also the combination that takes the form A,A,A such as b,b,b will appear for every element that repeats at least r times.

I find it complicated if we have a bigger multiset and some items repeat more than r times and some less than r times.

I only know some formulas like nCr and nPr but they don't work.

  • Are you looking for a way to generate the list of all combinations, or do you just need the number of combinations? – Mike Earnest Nov 16 '22 at 02:35
  • @MikeEarnest Only the number. I already found an algorithm to generate the list. – Software Carpenter Nov 16 '22 at 04:38
  • This is why your question is a duplicate. Suppose your multiset has $n$ distinct elements, where the $i^\text{th}$ element has multiplicity $m_i$. Choosing $r$ elements is equivalent to choosing numbers $a_1,a_2,\dots,a_n$ such that $0\le a_i\le m_i$ for all $i$, and for which $a_1+\dots+a_n=r$. The linked answer gives a complicated formula, and suggests generating function methods to compute it efficiently. – Mike Earnest Nov 16 '22 at 15:41

1 Answers1

0

You simply need to find the coefficient of $x^3$ in the expression $(x^0+x^1+x^2)(x^0+x^1+x^2+x^3)(x^0+x^1)(x^0+x^1)$
where the coefficients of x represent how many times a particular letter can occur, e.g. $a$ can occur $0,1,2$ times

This is known as an ordinary generating function

and gives the answer of $11$