1

I think my problem should be able to be solved with combination of multisets, but for some reason I do not get the right solution.

Example:

  • My Number List:(1,1,1,1,1,2) = (5*1, 1*2)
  • Example of a number of 3 combinations
  • Solution = 2 = (1,1,1) (1,1,2) as it is combination the order does not matter

If I am right (which I am sure I am not) I should use: $n=2$ $k=3$

$\binom{n+k-1}{k} = \binom{4}{3} = \frac{4!}{3!1!} = 4$ which is wrong.

I saw a few different solutions for the same problem which does not seems right for me, and there are some definitely wrong solutions. Is there a generic formula?

Edit 1:

After JMoravitz suggestion I spent a bit of time looking into the inclusion exclusion theorem. So these are my assumptions now:

Say I build a table for numbers I can use for simplification:

\begin{array}{|c|c|c|c| C | } \hline 1& 2 & 3 & 4 & list\\ \hline 5 &1 & & &1,1,1,1,1,2\\ \hline 4 &2 & & &1,1,1,1,2,2\\ \hline 4 &1 &1 & &1,1,1,1,2,3\\ \hline 2 &2 &2 & &1,1,2,2,3,3\\ \hline \end{array}

In all the cases $k = 3$ I assume at the first and second problem I should use the same calculation: $|A ∪ B| = |A| + |B| - |A ∩ B| $

The third and forth I assume should be this: $|A ∪ B ∪ C| = |A| + |B| + |C| - |A ∩ B| - |A ∩ C| - |B ∩ C| + |A ∩ B ∩ C|$

So in my head the first addition is always all the possibilities which should be calculated from the model above. I am wondering what would be $k$ and $n$ in the rest of the calculation like $ |A ∩ B ∩ C|$.

Daniel
  • 135
  • 2
    The answer of $\binom{n+k-1}{k}$ is for specifically if you have an unlimited number of each available. In this case $(1,1,1),(1,1,2),(1,2,2),(2,2,2)$ are the four that it counted. You however wanted to exclude those last two from the count. To do so, you can just remove the number which violate it, in this case being those with at least two $2$'s already, leaving only one left to account for: $n=2,k=1$ giving $\binom{2}{1}=2$ to be removed. – JMoravitz Nov 07 '17 at 23:10
  • 1
    To account for multiple upper bound limits on the number of each element available, apply inclusion-exclusion. – JMoravitz Nov 07 '17 at 23:11
  • @JMoravitz so first of all I calculate all the combinations, make sense, then I need to remove the ones which cannot happen cause of the finite number of the element in the list. So take a bit more complicated example, List = (1,1,1,1,2,3,4,5) select = 4 $all combination = 70$, $right combination = 16$ $Formula = ?$ I am looking how to apply inclusion-exclusion to this problem right now, but in the mean time, if you have the formula it would helpful. – Daniel Nov 08 '17 at 09:20
  • In your question, the answer can be found by counting the number of $1$s that are used. You only have two choices, $1$ or $2$. In your second example, choose the number of $1$s that are used. For each such choice, choose which of the other four numbers are used. $$\binom{4}{4} + \binom{4}{3} + \binom{4}{2} + \binom{4}{1} + \binom{4}{0} = 16$$ – N. F. Taussig Nov 08 '17 at 11:02
  • @N.F.Taussigbut this would just work if my number $1s>=number of selected $ is not it? so if I have a list of (1,1,1,2,2,3,4,5) this would not work, or would it? As there still would be all $combinations = 70$ with infinite numbers, but just $22$ with the finite list above (if I am right). I am looking for a total generic one, which I assume will be the one where I get all and subtract the "wrong ones". Please correct me if I am wrong – Daniel Nov 08 '17 at 11:10

1 Answers1

4

As per my suggestion to using inclusion-exclusion and your request for more information on the specific method I proposed, the events to use it on would be the event that we use too many $1$'s, the event that we used too many $2$'s, etc... Call these $A_1,A_2,A_3,\dots$. Call the set of combinations where we have an unlimited amount of each available $S$. The final total will be:

$$|S|-|A_1|-|A_2|-\dots+|A_1\cap A_2|+|A_1\cap A_3|+\dots-|A_1\cap A_2\cap A_3|-\dots\pm|A_1\cap\dots\cap A_n|$$

where we alternately subtract or add the intersections of one, two, three, and so on many events respectively.

Looking at a specific problem for now: How many $4$-combinations there are of the multiset $\{1,1,1,2,2,3,4,5\}$.

If we had an unlimited amount of each, it would be where $n=5,k=4$ and so total amount of combinations are $\binom{5+4-1}{4}=70$.

If we had used too many $1$'s, that would mean that we used strictly more than three $1$'s which implies we used four ones. We have zero remaining spots in our combination, so $|A_1|=1$

If we had used too many $2$'s, that would mean we used three or more $2$'s. Let us go ahead and use that many and count how many ways there are to fill the rest of the combination, again remembering that we are ignoring upper bounds for now. Here we would have $n=5,k=1$ so we have $\binom{5+1-1}{1}=5=|A_2|$

Similarly we calculate $|A_3|$ and $|A_4|$ and $|A_5|$ to be $\binom{5+2-1}{2}=15$. We aren't done yet though.

We continue and try to calculate $|A_1\cap A_2|,|A_1\cap A_3|,|A_1\cap A_4|,\dots,|A_1\cap A_2\cap A_3\cap A_4\cap A_5|$. Thankfully, the majority of these will be zero as it is impossible for us to have simultaneously taken too many of multiple numbers, but it is possible to have taken too many $3$'s and $4$'s or simultaneously taken too many $3$'s and $5$'s etc..., which would correspond to $|A_3\cap A_4|$ and $|A_3\cap A_5|$ etc... The only way to have taken too many $3$'s and $4$'s would be if we took two $3$'s and two $4$'s.

We have the final total being then $70-1-5-15-15-15+1+1+1=22$

Writing a fully generic formula will be incredibly wordy, but if you have $c_1,c_2,c_3,\dots$ amounts of $1$,$2$,$3$,... available respectively, you are choosing $k$ total and there are $n$ numbers available it will be something like this:

$$\sum\limits_{i=0}^n\left((-1)^i\sum\limits_{\Delta\subseteq [n]~:~|\Delta|=i}\binom{n+k-1-\sum\limits_{j\in\Delta}(c_j+1)}{n-1}\right)$$

Here, I take $[n]$ to mean $\{1,2,3,\dots,n\}$ as opposed to $\{0,1,2,\dots,n-1\}$ for convenience. It is worth pointing out the link to Sigma summation notation on wiki to remind you that you can notate in ways other than just running through the values from a start to a stop like in $\sum\limits_{i=0}^n$ and instead range over a set of values or range over a set of sets, etc...

JMoravitz
  • 79,518
  • Thank you for the detailed answer, just running through on the formula by using your example. So for $|A_2| n = 5, k = 1$ in your formula it would look: $\binom{5+1-1-(2+1)}{5-1}$ which just does not seem right for me. I am sure I am missing something as you do say that it should be $\binom{5+1-1}{1}$ – Daniel Nov 08 '17 at 17:34
  • 1
    @Daniel In my generic formula at the end, the same $n$ and $k$ are used throughout the entire problem. In the earlier example, I redefined $n$ and $k$ during each specific case so that you could hopefully follow where the binomial coefficient I later used came from. I opted to use $n-1$ as the bottom of the binomial coefficient to save from having to put another summation symbol in the bottom. If we were to talk about the same example, we would still have $n=5$ and $k=4$, not $k=1$. – JMoravitz Nov 08 '17 at 17:34
  • We would have $\binom{5+4-1-(2+1)}{5-1}=\binom{5}{4}=\binom{5}{1}=\binom{5+1-1}{1}$ – JMoravitz Nov 08 '17 at 17:35
  • Perfect, thank you again, and of course when in $\binom{n}{k}$ $n<k$ we just remove it from the equation – Daniel Nov 08 '17 at 17:49