In mathematics, a multiset (aka bag or mset) is a generalization of the concept of a set that, unlike a set, allows multiple instances of the multiset's elements. For example, {a, a, b} and {a, b} are different multisets although they are the same set. However, order does not matter, so {a, a, b} and {a, b, a} are the same multiset.
The multiplicity of an element is the number of instances of the element in a specific multiset. For example, an infinite number of multisets exist which contain only elements a and b, varying only by multiplicity:
- The unique set {a, b} contains only elements a and b, each having multiplicity 1
- In multiset {a, a, b}, a has multiplicity 2 and b has multiplicity 1
- In multiset {a, a, a, b, b, b}, a and b both have multiplicity 3