5
$\begingroup$

I've tried googling it and looking it up on this website but since I don't know the technical term for this calculation I ran out of luck. Basically, if I have a collection of numbers (each of which may have duplicates) how many unique combinations of $n$ numbers can I make by picking from that collection?

(This question addresses the same issue)

For example:

$C = \{ 1, 2, 2, 3, 3, 3 \}$ and I want to know how many combinations of $2$ numbers I can make.

Glancing over the collection, I can quickly see I can only make the following pairs:

$P = \{ (1,2),(1,3),(2,2),(2,3),(3,3) \}$

Which gives me the answer $|P|=5$.

But if I want to find the number of combinations of $4$ numbers, I can't just enumerate all the possible $4$-tuples because there's no way to make $(1,1,1,1)$ or $(1,2,2,2)$, for example.

Is there a way to calculate this in general using combinatorics?

$\endgroup$
6
  • $\begingroup$ $P$ is incomplete. What about $(2,1)$, $(3,1)$ and $(3,2)$? $\endgroup$
    – Air Mike
    Commented Aug 23, 2020 at 11:38
  • 2
    $\begingroup$ For combinations, the order of the numbers doesn't matter, so $(1,2)$ also accounts for $(2,1)$, same goes for $(2,3)$ and $(3,2)$ and $(1,3)$ and $(3,1)$. $\endgroup$ Commented Aug 23, 2020 at 11:39
  • $\begingroup$ I though you were constructing numbers out of these pairs, for example, $(1,2)$ would be $12$ and $(2,1)$ would be $21$. My mistake, now I got it :) $\endgroup$
    – Air Mike
    Commented Aug 23, 2020 at 11:41
  • $\begingroup$ This appears to be a duplicate of: Counting k-combinations excluding duplicate mathematically which is a duplicate of Number of k-combinations of a multiset which was tackled in detail in extended stars-and-bars problem(where the upper limit of the variable is bounded) ... I.e. how many times will we ask "How to count combinations of a multiset?" $\endgroup$
    – Vepir
    Commented Sep 5, 2020 at 6:18
  • 1
    $\begingroup$ @JansthcirlU No need to apologize, not your fault; I now see that the newest duplicate was asked on the same day as your question, that the older one (extended stars-and-bars) is not obvious for everyone to be equivalent to counting combinations of a multiset, and that the oldest one is actually not a good duplicate; And also all three require you to be familiar with the notion of a multiset, which you weren't familiar with (It is okay and good to be curious about new things). $\endgroup$
    – Vepir
    Commented Sep 5, 2020 at 8:12

1 Answer 1

2
$\begingroup$

Let's reduce the question to something I am sure you will be able to solve:

We will use the following notation:

$n$ will denote the number of different numbers (we assume the numbers are precisely $1,...,n$).

$a_k$ is the number of copies of the number $k$.

$s$ is the length of the tuples.

Let us for a second assume we have no restrictions, in this case, we have $n$ choices for each element, we need to choose $s$ in total and divide by the internal orderings: $$\frac{n^s}{s!}$$ However we counted illeagal combinations! so let us remove the ones in which we took at least $a_k + 1$ copies of the number $k$ for each $k\in[n]$, we need to choose where we put the $a_k+1$ copies, for that there are ${s\choose a_k+1}$ options, and we multiply by the ways to choose wats left. from those we have $$\sum_{1\leq k \leq n}{\frac{n^{s-a_k-1}}{(s-a_k-1)!}\cdot {s\choose a_k+1}}$$

Remember we need to remove those from the total: $$\frac{n^s}{s!} - \sum_{1\leq k \leq n}{\frac{n^{s-a_k-1}}{(s-a_k-1)!}\cdot {s\choose a_k+1}}$$

But wait! what if we exceeded the limit in more than one of the variables? We double count that... For this type of problems, we have the inclusion-exclusion formula with the events being $A_k$ means we exceeded the amount with the number $k$

$$\sum_{I \subseteq \{1,...,n\}}(-1)^{\vert I\vert}\cdot{\frac{n^{s-\sum _{k\in I}(a_k+1)}}{(s-\sum _{k\in I}(a_k+1))!}\cdot {s\choose \sum _{k\in I}(a_k+1)}}$$

With no more assumptions on the set of restrictions, I doubt the existence of an explicit formula, however, asymptotic can be calculated by assessing the first few terms.

$\endgroup$
1
  • 1
    $\begingroup$ Ah, my bad, I just woke up and saw you posted an answer! Give me a moment (likely many moments) to try and understand it ;) An example would be nice to make sense of the notation. $\endgroup$ Commented Aug 24, 2020 at 8:37

Not the answer you're looking for? Browse other questions tagged .