Formula for calculating the combination of a multiset taken r at a time?

58 Views Asked by At

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.

1

There are 1 best solutions below

2
On BEST ANSWER

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$