Stars and bars (combinatorics)

Last updated

In combinatorics, stars and bars (also called "sticks and stones", [1] "balls and bars", [2] and "dots and dividers" [3] ) is a graphical aid for deriving certain combinatorial theorems. It can be used to solve many simple counting problems, such as how many ways there are to put n indistinguishable balls into k distinguishable bins. [4] The solution to this particular problem is given by the binomial coefficient , which is the number of subsets of size k − 1 that can be formed from a set of size n + k − 1.

Contents

If, for example, there are two balls and three bins, then the number of ways of placing the balls is . The table shows the six possible ways of distributing the two balls, the strings of stars and bars that represent them (with stars indicating balls and bars separating bins from one another), and the subsets that correspond to the strings. As two bars are needed to separate three bins and there are two balls, each string contains two bars and two stars. Each subset indicates which of the four symbols in the corresponding string is a bar.

Six configurations of two balls in three bins and their star and bar represetations
Bin 1Bin 2Bin 3StringSubset of {1,2,3,4}
200★ ★ ||{3,4}
110||{2,4}
101||{2,3}
020| ★ ★ |{1,4}
011||{1,3}
002|| ★ ★{1,2}

Statements of theorems

The stars and bars method is often introduced specifically to prove the following two theorems of elementary combinatorics concerning the number of solutions to an equation.

Theorem one

For any pair of positive integers n and k, the number of k-tuples of positive integers whose sum is n is equal to the number of (k − 1)-element subsets of a set with n − 1 elements.

For example, if n = 10 and k = 4, the theorem gives the number of solutions to x1 + x2 + x3 + x4 = 10 (with x1, x2, x3, x4 > 0) as the binomial coefficient

where is the number of combinations of n − 1 elements taken k − 1 at a time.

This corresponds to compositions of an integer.

Theorem two

For any pair of positive integers n and k, the number of k-tuples of non-negative integers whose sum is n is equal to the number of multisets of size k − 1 taken from a set of size n + 1, or equivalently, the number of multisets of size n taken from a set of size k, and is given by

For example, if n = 10 and k = 4, the theorem gives the number of solutions to x1 + x2 + x3 + x4 = 10 (with x1, x2, x3, x4) as

where the multiset coefficient is the number of multisets of size n, with elements taken from a set of size k.

This corresponds to weak compositions of an integer. With k fixed, the numbers for n = 0, 1, 2, 3, … are those in the (k − 1)st diagonal of Pascal's triangle. For example, when k = 3 the nth number is the (n + 1)st triangular number, which falls on the second diagonal, 1, 3, 6, 10, ….

Proofs via the method of stars and bars

Theorem one proof

The problem of enumerating k-tuples whose sum is n is equivalent to the problem of counting configurations of the following kind: let there be n objects to be placed into k bins, so that all bins contain at least one object. The bins are distinguished (say they are numbered 1 to k) but the n objects are not (so configurations are only distinguished by the number of objects present in each bin). A configuration is thus represented by a k-tuple of positive integers.

The n objects are now represented as a row of n stars; adjacent bins are separated by bars. The configuration will be specified by indicating the boundary between the first and second bin, the boundary between the second and third bin, and so on. Hence k − 1 bars need to be placed between stars. Because no bin is allowed to be empty, there is at most one bar between any pair of stars. There are n − 1 gaps between stars and hence n − 1 positions in which a bar may be placed. A configuration is obtained by choosing k − 1 of these gaps to contain a bar; therefore there are configurations.

Example

With n = 7 and k = 3, start by placing seven stars in a line:

★ ★ ★ ★ ★ ★ ★
Fig. 1: Seven objects, represented by stars

Now indicate the boundaries between the bins:

★ ★ ★ ★ || ★ ★
Fig. 2: These two bars give rise to three bins containing 4, 1, and 2 objects

In general two of the six possible bar positions must be chosen. Therefore there are such configurations.


Theorem two proof

In this case, the weakened restriction of non-negativity instead of positivity means that we can place multiple bars between stars and that one or more bars also be placed before the first star and after the last star. In terms of configurations involving objects and bins, bins are now allowed to be empty.

Rather than a (k − 1)-set of bar positions taken from a set of size n − 1 as in the proof of Theorem one, we now have a (k − 1)-multiset of bar positions taken from a set of size n + 1 (since bar positions may repeat and since the ends are now allowed bar positions). An alternative interpretation in terms of multisets is the following: there is a set of k bin labels from which a multiset of size n is to be chosen, the multiplicity of a bin label in this multiset indicating the number of objects placed in that bin. The equality can also be understood as an equivalence of different counting problems: the number of k-tuples of non-negative integers whose sum is n equals the number of (n + 1)-tuples of non-negative integers whose sum is k − 1, which follows by interchanging the roles of bars and stars in the diagrams representing configurations.

To see the expression directly, observe that any arrangement of stars and bars consists of a total of n + k − 1 symbols, n of which are stars and k − 1 of which are bars. Thus, we may lay out n + k − 1 slots and choose k − 1 of these to contain bars (or, equivalently, choose n of the slots to contain stars).

Example

When n = 7 and k = 5, the tuple (4, 0, 1, 2, 0) may be represented by the following diagram:

★ ★ ★ ★ ||| ★ ★ |
Fig. 3: These four bars give rise to five bins containing 4, 0, 1, 2, and 0 objects

If possible bar positions are labeled 1, 2, 3, 4, 5, 6, 7, 8 with label i 7 corresponding to a bar preceding the ith star and following any previous star and 8 to a bar following the last star, then this configuration corresponds to the (k − 1)-multiset {5,5,6,8}, as described in the proof of Theorem two. If bins are labeled 1, 2, 3, 4, 5, then it also corresponds to the n-multiset {1,1,1,1,3,4,4}, also as described in the proof of Theorem two.

Relation between Theorems one and two

Theorem one can be restated in terms of Theorem two, because the requirement that each variable be positive can be imposed by shifting each variable by −1, and then requiring only that each variable be non-negative.

For example:

with

is equivalent to:

with

where for each .

Further examples

Four cookies are distributed between Tom, Dick, and Harry (TDH) in such a way that each gets at least one cookie. The 4 cookies are traditionally represented as stars (****). But here, they are shown as cookie-colored circles (
@media screen{html.skin-theme-clientpref-night .mw-parser-output div:not(.notheme)>.tmp-color,html.skin-theme-clientpref-night .mw-parser-output p>.tmp-color,html.skin-theme-clientpref-night .mw-parser-output table:not(.notheme) .tmp-color{color:inherit!important}}@media screen and (prefers-color-scheme:dark){html.skin-theme-clientpref-os .mw-parser-output div:not(.notheme)>.tmp-color,html.skin-theme-clientpref-os .mw-parser-output p>.tmp-color,html.skin-theme-clientpref-os .mw-parser-output table:not(.notheme) .tmp-color{color:inherit!important}}
****). The 3 gaps between the cookies are indicated by red carets (^ ^ ^). With three people, we need two bar symbols (| |) to occupy any two of the three gaps. Hence the problem reduces to finding the binomial coefficient
(
3
2
)
.
{\displaystyle {\tbinom {3}{2}}.}
Also shown are the three corresponding 3-compositions of 4. Colored circle starsbars 1.svg
Four cookies are distributed between Tom, Dick, and Harry (TDH) in such a way that each gets at least one cookie. The 4 cookies are traditionally represented as stars (****). But here, they are shown as cookie-colored circles (●●●●). The 3 gaps between the cookies are indicated by red carets (^ ^ ^). With three people, we need two bar symbols (| |) to occupy any two of the three gaps. Hence the problem reduces to finding the binomial coefficient Also shown are the three corresponding 3-compositions of 4.
The three-choose-two combination yields two results, depending on whether a bin is allowed to have zero items. In both results the number of bins is 3. If zero is not allowed, the number of cookies should be n = 6, as described in the previous figure. If zero is allowed, the number of cookies should only be n = 3. Stars bars 5 take 2.svg
The three-choose-two combination yields two results, depending on whether a bin is allowed to have zero items. In both results the number of bins is 3. If zero is not allowed, the number of cookies should be n = 6, as described in the previous figure. If zero is allowed, the number of cookies should only be n = 3.

Example 1

If one wishes to count the number of ways to distribute seven indistinguishable one dollar coins among Amber, Ben, and Curtis so that each of them receives at least one dollar, one may observe that distributions are essentially equivalent to tuples of three positive integers whose sum is 7. (Here the first entry in the tuple is the number of coins given to Amber, and so on.) Thus Theorem 1 applies, with n = 7 and k = 3, and there are ways to distribute the coins.

Example 2

If n = 5, k = 4, and the k bin labels are a, b, c, d, then ★|★★★||★ could represent either the 4-tuple (1, 3, 0, 1), or the multiset of bar positions {2, 5, 5}, or the multiset of bin labels {a, b, b, b, d}. The solution of this problem should use Theorem 2 with n = 5 stars and k – 1 = 3 bars to give configurations.

Example 3

In the proof of Theorem two there can be more bars than stars, which cannot happen in the proof of Theorem one.

So, for example, 10 balls into 7 bins gives configurations, while 7 balls into 10 bins gives configurations, and 6 balls into 11 bins gives configurations.

Example 4

The graphical method was used by Paul Ehrenfest and Heike Kamerlingh Onnes—with symbol ε (quantum energy element) in place of a star and the symbol 0 in place of a bar—as a simple derivation of Max Planck's expression for the number of "complexions" for a system of "resonators" of a single frequency. [5] [6]

By complexions (microstates) Planck meant distributions of P energy elements ε over N resonators. [7] [8] The number R of complexions is

The graphical representation of each possible distribution would contain P copies of the symbol ε and N – 1 copies of the symbol 0. In their demonstration, Ehrenfest and Kamerlingh Onnes took N = 4 and P = 7 (i.e., R = 120 combinations). They chose the 4-tuple (4, 2, 0, 1) as the illustrative example for this symbolic representation: εεεε0εε00ε.

Relation to generating functions

The enumerations of Theorems one and two can also be found using generating functions involving simple rational expressions. The two cases are very similar; we will look at the case when , that is, Theorem two first. There is only one configuration for a single bin and any given number of objects (because the objects are not distinguished). This is represented by the generating function

The series is a geometric series, and the last equality holds analytically for |x| < 1, but is better understood in this context as a manipulation of formal power series. The exponent of x indicates how many objects are placed in the bin.

Each additional bin is represented by another factor of ; the generating function for k bins is

,

where the multiplication is the Cauchy product of formal power series.

To find the number of configurations with n objects, we want the coefficient of (denoted by prefixing the expression for the generating function with ), that is,

.

This coefficient can be found using binomial series and agrees with the result of Theorem two, namely .

This Cauchy product expression is justified via stars and bars: the coefficient of in the expansion of the product

is the number of ways of obtaining the nth power of x by multiplying one power of x from each of the k factors. So the stars represent xs and a bar separates the xs coming from one factor from those coming from the next factor.

For the case when , that is, Theorem one, no configuration has an empty bin, and so the generating function for a single bin is

.

The Cauchy product is therefore , and the coefficient of is found using binomial series to be .


See also

Related Research Articles

<span class="mw-page-title-main">Binomial coefficient</span> Number of subsets of a given size

In mathematics, the binomial coefficients are the positive integers that occur as coefficients in the binomial theorem. Commonly, a binomial coefficient is indexed by a pair of integers nk ≥ 0 and is written It is the coefficient of the xk term in the polynomial expansion of the binomial power (1 + x)n; this coefficient can be computed by the multiplicative formula

In elementary algebra, the binomial theorem describes the algebraic expansion of powers of a binomial. According to the theorem, the power expands into a polynomial with terms of the form , where the exponents and are nonnegative integers satisfying and the coefficient of each term is a specific positive integer depending on and . For example, for ,

In mathematics, a combination is a selection of items from a set that has distinct members, such that the order of selection does not matter. For example, given three fruits, say an apple, an orange and a pear, there are three combinations of two that can be drawn from this set: an apple and a pear; an apple and an orange; or a pear and an orange. More formally, a k-combination of a set S is a subset of k distinct elements of S. So, two combinations are identical if and only if each combination has the same members. If the set has n elements, the number of k-combinations, denoted by or , is equal to the binomial coefficient

In mathematics, Pascal's triangle is an infinite triangular array of the binomial coefficients which play a crucial role in probability theory, combinatorics, and algebra. In much of the Western world, it is named after the French mathematician Blaise Pascal, although other mathematicians studied it centuries before him in Persia, India, China, Germany, and Italy.

In linear algebra, Cramer's rule is an explicit formula for the solution of a system of linear equations with as many equations as unknowns, valid whenever the system has a unique solution. It expresses the solution in terms of the determinants of the (square) coefficient matrix and of matrices obtained from it by replacing one column by the column vector of right-sides of the equations. It is named after Gabriel Cramer, who published the rule for an arbitrary number of unknowns in 1750, although Colin Maclaurin also published special cases of the rule in 1748, and possibly knew of it as early as 1729.

In mathematics, the falling factorial is defined as the polynomial

In mathematics, Bertrand's postulate states that, for each , there is a prime such that . First conjectured in 1845 by Joseph Bertrand, it was first proven by Chebyshev, and a shorter but also advanced proof was given by Ramanujan.

In mathematics, a multiset is a modification of the concept of a set that, unlike a set, allows for multiple instances for each of its elements. The number of instances given for each element is called the multiplicity of that element in the multiset. As a consequence, an infinite number of multisets exist that contain only elements a and b, but vary in the multiplicities of their elements:

In mathematics, a monomial is, roughly speaking, a polynomial which has only one term. Two definitions of a monomial may be encountered:

  1. A monomial, also called a power product or primitive monomial, is a product of powers of variables with nonnegative integer exponents, or, in other words, a product of variables, possibly with repetitions. For example, is a monomial. The constant is a primitive monomial, being equal to the empty product and to for any variable . If only a single variable is considered, this means that a monomial is either or a power of , with a positive integer. If several variables are considered, say, then each can be given an exponent, so that any monomial is of the form with non-negative integers.
  2. A monomial in the first sense multiplied by a nonzero constant, called the coefficient of the monomial. A primitive monomial is a special case of a monomial in this second sense, where the coefficient is . For example, in this interpretation and are monomials.

In combinatorial mathematics, the Bell polynomials, named in honor of Eric Temple Bell, are used in the study of set partitions. They are related to Stirling and Bell numbers. They also occur in many applications, such as in Faà di Bruno's formula.

In mathematics, the multinomial theorem describes how to expand a power of a sum in terms of powers of the terms in that sum. It is the generalization of the binomial theorem from binomials to multinomials.

Multi-index notation is a mathematical notation that simplifies formulas used in multivariable calculus, partial differential equations and the theory of distributions, by generalising the concept of an integer index to an ordered tuple of indices.

In combinatorics, Bertrand's ballot problem is the question: "In an election where candidate A receives p votes and candidate B receives q votes with p > q, what is the probability that A will be strictly ahead of B throughout the count under the assumption that votes are counted in a randomly picked order?" The answer is

In mathematics, the Gaussian binomial coefficients are q-analogs of the binomial coefficients. The Gaussian binomial coefficient, written as or , is a polynomial in q with integer coefficients, whose value when q is set to a prime power counts the number of subspaces of dimension k in a vector space of dimension n over , a finite field with q elements; i.e. it is the number of points in the finite Grassmannian .

<span class="mw-page-title-main">Central binomial coefficient</span> Sequence of numbers ((2n) choose (n))

In mathematics the nth central binomial coefficient is the particular binomial coefficient

In combinatorics, the twelvefold way is a systematic classification of 12 related enumerative problems concerning two finite sets, which include the classical problems of counting permutations, combinations, multisets, and partitions either of a set or of a number. The idea of the classification is credited to Gian-Carlo Rota, and the name was suggested by Joel Spencer.

In number theory, Lucas's theorem expresses the remainder of division of the binomial coefficient by a prime number p in terms of the base p expansions of the integers m and n.

In mathematics, a univariate polynomial of degree n with real or complex coefficients has n complex roots, if counted with their multiplicities. They form a multiset of n points in the complex plane. This article concerns the geometry of these points, that is the information about their localization in the complex plane that can be deduced from the degree and the coefficients of the polynomial.

In mathematics, Kummer's theorem is a formula for the exponent of the highest power of a prime number p that divides a given binomial coefficient. In other words, it gives the p-adic valuation of a binomial coefficient. The theorem is named after Ernst Kummer, who proved it in a paper,.

In combinatorial mathematics and statistics, the Fuss–Catalan numbers are numbers of the form

References

  1. Batterson, J. Competition Math for Middle School. Art of Problem Solving.
  2. Flajolet, Philippe; Sedgewick, Robert (June 26, 2009). Analytic Combinatorics. Cambridge University Press. ISBN   978-0-521-89806-5.
  3. "Art of Problem Solving". artofproblemsolving.com. Retrieved 2021-10-26.
  4. Feller, William (1968). An Introduction to Probability Theory and Its Applications. Vol. 1 (3rd ed.). Wiley. p. 38.
  5. Ehrenfest, Paul; Kamerlingh Onnes, Heike (1914). "Simplified deduction of the formula from the theory of combinations which Planck uses as the basis of his radiation theory". Proceedings of the KNAW. 17: 870–873. Retrieved 16 May 2024.
  6. Ehrenfest, Paul; Kamerlingh Onnes, Heike (1915). "Simplified deduction of the formula from the theory of combinations which Planck uses as the basis of his radiation theory". The London, Edinburgh, and Dublin Philosophical Magazine and Journal of Science. Series 6. 29 (170): 297–301. doi:10.1080/14786440208635308 . Retrieved 5 December 2020.
  7. Planck, Max (1901). "Ueber das Gesetz der Energieverteilung im Normalspectrum". Annalen der Physik. 309 (3): 553–563. Bibcode:1901AnP...309..553P. doi: 10.1002/andp.19013090310 .
  8. Gearhart, C. (2002). "Planck, the Quantum, and the Historians" (PDF). Phys. Perspect. 4 (2): 170–215. Bibcode:2002PhP.....4..170G. doi:10.1007/s00016-002-8363-7 . Retrieved 16 May 2024.

Further reading