Stars and bars (combinatorics)
In the context of combinatorial mathematics, stars and bars refers to a trick used to derive certain combinatorial theorems.
Theorem one
There are distinct positive integer-valued vectors of length whose components sum to .
Theorem two
There are distinct nonnegative integer-valued vectors of length whose components sum to .
Derivation of theorem one
Imagine we have indistinguishable objects to be placed into bins such that all bins contain at least one object. We may represent the objects with side-by-side stars,
★★★★★★ |
(seven objects) |
and we may represent the partitions between the bins with bars:
★★★★ | | | ★ | | | ★★ | |
(an allocation into three bins containing 4, 1, and 2 objects) |
In fact for stars (objects), there are possible places a bar (bin partition) could be placed such that all bins contain at least one object. Therefore (see combination), there are
ways to allocate objects to bins such that each bin contains at least one object. The theorem follows from the fact that we may represent the number of objects in the bins by a vector of positive integers.
Derivation of the theorem two
This follows from applying theorem one to objects, and ensuring that exactly one of each of the additional objects ends up in its own bin.
Example
Seven indistinguishable one dollar coins are to be distributed among Amber, Ben and Curtis so that each of them receives at least one dollar. Thus the stars and bars apply with and ; hence there are
ways to distribute the coins.
References
Pitman, Jim (1993). Probability. Berlin: Springer-Verlag. ISBN 0-387-97974-3.