# Counting with multisets

**URL:** <https://boards.straightdope.com/t/counting-with-multisets/354062>\
**Category:** Factual Questions\
**Created:** [April 24, 2006, 10:39pm UTC](https://boards.straightdope.com/t/counting-with-multisets/354062 "2006-04-24T22:39:38Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![ultrafilter](https://avatars.discourse-cdn.com/v4/letter/u/3d9bf3/32.png) [@ultrafilter](https://boards.straightdope.com/u/ultrafilter)\
**Post date:** [April 24, 2006, 10:39pm UTC](https://boards.straightdope.com/t/counting-with-multisets/354062/1 "2006-04-24T22:39:38Z")

</div>

This is for work, not school (and I’d rather not say anything else on that). I’ve got a multiset {(a[sub]i[/sub], n[sub]i[/sub]) | 1 \< i \< k}. I need to figure out a couple things:

1. The total number of subsets. I think this is 2^sum(n[sub]i[/sub] + 1, 1 \< i \< k) (not using the {sup}{/sup} tags because it’s too hard to read).

2. The number of subsets with at most one of each element. I think this product(n[sub]i[/sub] + 1, 1 \< i \< k).

Do these results seem right?

---

<div class="post-metadata">

**Author:** ![Cabbage](https://avatars.discourse-cdn.com/v4/letter/c/f07891/32.png) [@Cabbage](https://boards.straightdope.com/u/Cabbage)\
**Post date:** [April 24, 2006, 10:54pm UTC](https://boards.straightdope.com/t/counting-with-multisets/354062/2 "2006-04-24T22:54:30Z")

</div>

I might be missing something here. I wasn’t familiar with the term “multiset”, so I looked it up on [www.mathworld.com](http://www.mathworld.com) . I’m reading your notation as a[sub]i[/sub] being an element of the multiset with multiplicity n[sub]i[/sub]. Is that correct? And a[sub]i[/sub] is distinct from a[sub]j[/sub] if and only if i and j are distinct.

Anyway, the way I’m reading it, I would think of {(a[sub]i[/sub], n[sub]i[/sub]) | 1 \< i \< k} as essentially being a set with N elements, where N is the sum of just the n[sub]i[/sub]'s (not the sum of n[sub]i[/sub]+1). So the total number of subsets would be 2[sup]N[/sup].

For the second part, since you have k distinct elements, I would think the number of subsets with at most one element would be 2[sup]k[/sup] (for each of the k elements, you have two choices–either include it or don’t).

---

<div class="post-metadata">

**Author:** ![Cabbage](https://avatars.discourse-cdn.com/v4/letter/c/f07891/32.png) [@Cabbage](https://boards.straightdope.com/u/Cabbage)\
**Post date:** [April 24, 2006, 10:58pm UTC](https://boards.straightdope.com/t/counting-with-multisets/354062/3 "2006-04-24T22:58:13Z")

</div>

My last sentence should read:

For the second part, since you have k distinct elements, I would think the number of subsets with at most one **of each** element would be 2[sup]k[/sup] (for each of the k elements, you have two choices–either include it or don’t).

---

<div class="post-metadata">

**Author:** ![Omphaloskeptic](https://avatars.discourse-cdn.com/v4/letter/o/bcef8e/32.png) [@Omphaloskeptic](https://boards.straightdope.com/u/Omphaloskeptic)\
**Post date:** [April 24, 2006, 11:49pm UTC](https://boards.straightdope.com/t/counting-with-multisets/354062/4 "2006-04-24T23:49:24Z")

</div>

I agree with **Cabbage** for (2); limiting the subset to contain at most one of each element means we can just think of the multiset as the k-element set {a[sub]i[/sub]}.

For (1), as I interpret it, a “subset” (sub-multiset?) is a set {(a[sub]i[/sub],m[sub]i[/sub]): 1 \< i \< k, 0 \< m[sub]i[/sub] \< n[sub]i[/sub]}; there are thus prod(n[sub]i[/sub]+1) such sub-multisets (the expression **ultrafilter** gave for (2)).

---

<div class="post-metadata">

**Author:** ![Cabbage](https://avatars.discourse-cdn.com/v4/letter/c/f07891/32.png) [@Cabbage](https://boards.straightdope.com/u/Cabbage)\
**Post date:** [April 25, 2006, 12:00am UTC](https://boards.straightdope.com/t/counting-with-multisets/354062/5 "2006-04-25T00:00:30Z")

</div>

Yeah, now that I think about it, I agree with you on the first one, as well, **Omphaloskeptic**.

I was thinking of, for example, the multiset {1,1,1}. What I was originally thinking of would imply that the "1"s are distinct. So, for example, the subsets {1} and {1} could be distinct if in the first case we’re taking the 1 on the left, and in the second case we’re taking the 1 on the right (and we’d have a third distinct singleton set {1} by taking the 1 in the middle).

Of course, now that I think about it, I don’t think that’s the idea behind a multiset. A subset of {1,1,1} will simply have 0, 1, 2, or 3 "1"s, for a total of exactly four distinct subsets. In general, the number of subsets will be the product of (n[sub]i[/sub]+1), like you said.

---

<div class="post-metadata">

**Author:** ![ultrafilter](https://avatars.discourse-cdn.com/v4/letter/u/3d9bf3/32.png) [@ultrafilter](https://boards.straightdope.com/u/ultrafilter)\
**Post date:** [April 25, 2006, 12:30am UTC](https://boards.straightdope.com/t/counting-with-multisets/354062/6 "2006-04-25T00:30:46Z")

</div>

Yeah, you guys are right, which means I’m using the wrong model for my problem. What I want is that any two elements of the set are distinguishable, but each one has a family associated with it. So let’s try this as counting subsets of the set A = A[sub]1[/sub] [symbol]È[/symbol] A[sub]2[/sub] [symbol]È[/symbol] … [symbol]È[/symbol] A[sub]k[/sub], where the A[sub]i[/sub] are pairwise disjoint, |A[sub]i[/sub]| = n[sub]i[/sub], and N = n[sub]1[/sub] + n[sub]2[/sub] + … n[sub]k[/sub].

Here there are 2[sup]N[/sup] possible subsets of A, which means I was over-counting earlier. As for subsets of A with at most one element from each A[sub]i[/sub], there are [symbol]P[/symbol][sub]1 \< i \< k[/sub](n[sub]i[/sub] + 1). How’s that look?

---

<div class="post-metadata">

**Author:** ![Omphaloskeptic](https://avatars.discourse-cdn.com/v4/letter/o/bcef8e/32.png) [@Omphaloskeptic](https://boards.straightdope.com/u/Omphaloskeptic)\
**Post date:** [April 25, 2006, 1:01am UTC](https://boards.straightdope.com/t/counting-with-multisets/354062/7 "2006-04-25T01:01:59Z")

</div>

[QUOTE=ultrafilter]  
How’s that look?  
[/QUOTE]  
Looks good to me.
