maths.free › Combinatorics & Graph Theory › Counting › Stirling numbers of the second kind
Stirling numbers of the second kind
In mathematics, particularly in combinatorics, a Stirling number of the second kind (or Stirling partition number) is the number of ways to partition a set of n objects into k non-empty subsets and is denoted by or .
Stirling numbers of the second kind
In mathematics, particularly in combinatorics, a Stirling number of the second kind (or Stirling partition number) is the number of ways to partition a set of n objects into k non-empty subsets and is denoted by \(S(n,k)\) or \(\textstyle \left\{{n\atop k}\right\}\). Stirling numbers of the second kind occur in combinatorics and the study of partitions. They are named after James Stirling.
The Stirling numbers of the first and second kind can be understood as inverses of one another when viewed as triangular matrices. This article is devoted to specifics of Stirling numbers of the second kind. Identities linking the two kinds appear in the article on Stirling numbers.
Definition
The Stirling numbers of the second kind, written \(S(n,k)\) or \(\lbrace\textstyle{n\atop k}\rbrace\) or with other notations, count the number of ways to partition a set of \(n\) labelled objects into \(k\) nonempty unlabelled subsets. Equivalently, they count the number of different equivalence relations with precisely \(k\) equivalence classes that can be defined on an \(n\) element set. In fact, there is a bijection between the set of partitions and the set of equivalence relations on a given set. Obviously,
\(\left\{ {n \atop 0} \right\} = 0\) for n ≥ 1, \(\left\{ {n \atop n} \right\} = 1\) for n ≥ 0, and \(\left\{ {n \atop 1}\right\} = 1\) for n ≥ 1,
as there is no empty partition of a nonempty set, the only way to partition an n-element set into n parts is to put each element of the set into its own part, and the only way to partition a nonempty set into one part is to put all of the elements in the same part. Unlike Stirling numbers of the first kind, they can be calculated using a one-sum formula:
\(\left\{ {n \atop k}\right\} = \frac{1}{k!}\sum_{i=0}^k (-1)^{k-i} \binom{k}{i} i^n = \sum_{i=0}^k \frac{(-1)^{k-i} i^n}{(k-i)!i!}.\)
The Stirling numbers of the first kind may be characterized as the numbers that arise when one expresses powers of an indeterminate x in terms of the falling factorials
\((x)_n=x(x-1)(x-2)\cdots(x-n+1) .\)
Notation
Various notations have been used for Stirling numbers of the second kind. The brace notation \(\textstyle \lbrace{n\atop k}\rbrace\) was used by Imanuel Marx and Antonio Salmeri in 1962 for variants of these numbers. This led Knuth to use it, as shown here, in the first volume of The Art of Computer Programming (1968). According to the third edition of The Art of Computer Programming, this notation was also used earlier by Jovan Karamata in 1935. The notation S(n, k) was used by Richard Stanley in his book Enumerative Combinatorics and also, much earlier, by many other writers.
The notations used on this page for Stirling numbers are not universal, and may conflict with notations in other sources.
Relation to Bell numbers
Since the Stirling number \(\left\{ {n \atop k} \right\}\) counts set partitions of an n-element set into k parts, the sum
\(B_n=\sum_{k=0}^n \left\{ {n \atop k} \right\}\)
over all values of k is the total number of partitions of a set with n members. This number is known as the nth Bell number.
Analogously, the ordered Bell numbers can be computed from the Stirling numbers of the second kind via
\(a_n = \sum_{k=0}^n k! \left\{ {n \atop k}\right\}.\)
Table of values
Below is a triangular array of values for the Stirling numbers of the second kind (sequence A048993 in the OEIS):
As with the binomial coefficients, this table could be extended to k > n, but the entries would all be 0.
Recurrence relation
Stirling numbers of the second kind obey the recurrence relation (first discovered by Masanobu Saka in his 1782 Sanpō-Gakkai):
\left\{{n+1\atop k}\right\} = k \left\{{ n \atop k }\right\} + \left\{{n\atop k-1}\right\}
\quad \mbox{for} \; 0 with initial conditions \(\left\{{ n \atop n }\right\} = 1 \quad \mbox{ for} \; n \geq 0 \quad \text{ and } \quad
\left\{{ n \atop 0 }\right\} = \left\{{ 0 \atop n }\right\} = 0 \quad \text{ for } n>0 \text{.}\) For instance, the number 25 in column k = 3 and row n = 5 is given by 25 = 7 + (3×6), where 7 is the number above and to the left of 25, 6 is the number above 25 and 3 is the column containing the 6. To prove this recurrence, observe that a partition of the \(n+1\) objects into k nonempty subsets either contains the \((n+1)\)-th object as a singleton or it does not. The number of ways that the singleton is one of the subsets is given by \(\left\{{ n \atop k-1 }\right\}\) since we must partition the remaining n objects into the available \(k-1\) subsets. In the other case the \((n+1)\)-th object belongs to a subset containing other objects. The number of ways is given by \(k \left\{{ n \atop k }\right\}\) since we partition all objects other than the \((n+1)\)-th into k subsets, and then we are left with k choices for inserting object \(n+1\). Summing these two values gives the desired result. Another recurrence relation is given by \(\begin{aligned}
\left\{ {n \atop k} \right\} & = \frac{1}{n-k} \sum_{j=2}^{n-k+1} (j-2)! \binom{-k}{j} \left\{ {n \atop k+j-1} \right\}, \\
\left\{ {n \atop n} \right\} & = 1.
\end{aligned}\) \(\begin{aligned}
\left\{ {n \atop k} \right\} & = \frac{1}{n-k} \sum_{j=2}^{n-k+1} \binom{n}{j} \left\{ {n-j+1 \atop k} \right\} (-1)^j, \\
\left\{ {n \atop n} \right\} & = 1.
\end{aligned}\) Condensed: the full section is in Wikipedia.
Simple identities
Some simple identities include
\(\left\{ {n \atop n-1}\right\} = \binom{n}{2}.\)
This is because dividing n elements into n − 1 sets necessarily means dividing it into one set of size 2 and n − 2 sets of size 1. Therefore we need only pick those two elements;
and
\(\left\{ {n \atop 2}\right\} = 2^{n-1}-1.\)
To see this, first note that there are 2 ordered pairs of complementary subsets A and B. In one case, A is empty, and in another B is empty, so 2 − 2 ordered pairs of subsets remain. Finally, since we want unordered pairs rather than ordered pairs we divide this last number by 2, giving the result above.
Another explicit expansion of the recurrence-relation gives identities in the spirit of the above example.
Identities
The table in section 6.1 of Concrete Mathematics provides a plethora of generalized forms of finite sums involving the Stirling numbers. Several particular finite sums relevant to this article include
\(\begin{aligned} \left\{{n+1\atop k+1}\right\} &= \sum_{j=k}^n {n \choose j} \left\{{ j \atop k }\right\}\\ \left\{{n+1\atop k+1}\right\} &= \sum_{j=k}^n (k+1)^{n-j} \left\{{j \atop k}\right\}\\ \left\{{n+k+1 \atop k}\right\} &= \sum_{j=0}^k j \left\{{ n+j \atop j }\right\} \\ \left\{{n \atop \ell+m } \right\} \binom{\ell+m}{\ell} &= \sum_k \left\{{k \atop \ell} \right\} \left\{{n-k \atop m } \right\} \binom{n}{k} \end{aligned}\)
Explicit formula
The Stirling numbers of the second kind are given by the explicit formula:
\(\left\{ {n \atop k} \right\} =\frac{1}{k!}\sum_{j=0}^{k}(-1)^{k-j}{k \choose j} j^n =\sum_{j=0}^k \frac{(-1)^{k-j} j^n}{(k-j)!j!} .\)
This can be derived by using inclusion-exclusion to count the surjections from n to k and using the fact that the number of such surjections is \(k! \left\{ {n \atop k} \right\}\).
Additionally, this formula is a special case of the kth forward difference of the monomial \(x^n\) evaluated at x = 0:
\(\Delta^k x^n = \sum_{j=0}^{k}(-1)^{k-j}{k \choose j} (x+j)^n.\)
Because the Bernoulli polynomials may be written in terms of these forward differences, one immediately obtains a relation in the Bernoulli numbers:
\(B_m(0)=\sum_{k=0}^m \frac {(-1)^k k!}{k+1} \left\{ {m \atop k} \right\}.\)
The evaluation of incomplete exponential Bell polynomial Bn,k(x1,x2,...) on the sequence of ones equals a Stirling number of the second kind:
\(\left\{{n\atop k}\right\} = B_{n,k}(1,1,\dots,1).\)
Another explicit formula given in the NIST Handbook of Mathematical Functions is
\(\left\{ {n \atop k} \right\} = \sum_{ \begin{array}{c} c_1 + \ldots + c_k = n-k\\ c_1, \ldots,\ c_k\ \geq\ 0 \end{array} } 1^{c_1} 2^{c_2} \cdots k^{c_k}\)
Parity
The parity of a Stirling number of the second kind is same as the parity of a related binomial coefficient:
\(\left\{ {n\atop k}\right\}\equiv \binom{z}{w}\ \pmod{2},\) where \(z = n - \left\lceil\displaystyle\frac{k + 1}{2}\right\rceil,\ w = \left\lfloor\displaystyle\frac{k - 1}{2}\right\rfloor.\)
This relation is specified by mapping n and k coordinates onto the Sierpiński triangle.
More directly, let two sets contain positions of 1's in binary representations of results of respective expressions:
\(\begin{aligned} \mathbb{A}:\ \sum_{i\in\mathbb{A}} 2^i &= n-k,\\ \mathbb{B}:\ \sum_{j\in\mathbb{B}} 2^j &= \left\lfloor\dfrac{k - 1}{2}\right\rfloor.\\ \end{aligned}\)
One can mimic a bitwise AND operation by intersecting these two sets:
\(\begin{Bmatrix}n\\k\end{Bmatrix}\,\bmod\,2 = \begin{cases} 0, & \mathbb{A}\cap\mathbb{B}\ne\empty;\\ 1, & \mathbb{A}\cap\mathbb{B}=\empty; \end{cases}\)
to obtain the parity of a Stirling number of the second kind in O(1) time. In pseudocode:
\(\begin{Bmatrix}n\\k\end{Bmatrix}\,\bmod\,2 := \left[\left( \left(n-k\right)\ \And\ \left( \left(k-1\right)\,\mathrm{div}\,2 \right)\right) = 0\right];\)
where \(\left[b\right]\) is the Iverson bracket.
The parity of a central Stirling number of the second kind \(\textstyle \left\{{2n\atop n}\right\}\) is odd if and only if \(n\) is a fibbinary number, a number whose binary representation has no two consecutive 1s.
Generating functions
For a fixed integer n, the ordinary generating function for Stirling numbers of the second kind \(\left\{ {n\atop 0} \right\}, \left\{ {n\atop 1} \right\}, \ldots\) is given by
\(\sum_{k=0}^n \left\{ {n\atop k} \right\} x^k = T_n(x),\)
where \(T_n(x)\) are Touchard polynomials. If one sums the Stirling numbers against the falling factorial instead, one can show the following identities, among others:
\(\sum_{k=0}^n \left\{ {n\atop k} \right\} (x)_k = x^n\)
and
\(\sum_{k=1}^{n+1} \left\{ {n+1 \atop k} \right\} (x-1)_{k-1} = x^n,\)
which has special case
\(\sum_{k=0}^n \left\{ {n\atop k} \right\} (n)_k = n^n.\)
For a fixed integer k, the Stirling numbers of the second kind have rational ordinary generating function
\(\sum_{n=k}^\infty \left\{ {n\atop k} \right\} x^{n - k} = \prod_{r=1}^k \frac{1}{1-rx} = \frac{1}{x^{k + 1} (1/x)_{k+1}}\)
and have an exponential generating function given by
\(\sum_{n=k}^\infty \left\{ {n \atop k}\right\} \frac{x^n}{n!} = \frac{(e^x-1)^k}{k!}.\)
A mixed bivariate generating function for the Stirling numbers of the second kind is
\(\sum_{k=0}^{\infty} \sum_{n=k}^{\infty} \left\{ {n \atop k} \right\} \frac{x^n}{n!} y^k = e^{y(e^x-1)}.\)
Lower and upper bounds
If \(n \geq 2\) and \(1 \leq k \leq n-1\), then
\(\frac{1}{2}(k^2+k+2)k^{n-k-1}-1 \leq \left\{{n \atop k}\right\} \leq \frac{1}{2}{n \choose k} k^{n-k}\).
Asymptotic approximation
For fixed value of \(k,\) the asymptotic value of the Stirling numbers of the second kind as \(n\rightarrow \infty\) is given by
\(\left\{{n \atop k}\right\} \underset{n \to \infty}{\sim} \frac{k^n}{k!}.\)
If \(k = o(\sqrt{n})\) (where o denotes the little o notation) then
\(\left\{{n+k \atop n}\right\} \underset{n \to \infty}{\sim} \frac{n^{2k}}{2^k k!}.\)
A uniformly valid approximation also exists: for all k such that 1 < k < n, one has
\(\left\{{n \atop k}\right\} \sim \sqrt{\frac{v-1}{v(1-G)}} \left(\frac{v-1}{v-G}\right)^{n-k} \frac{k^n}{n^k} e^{k(1-G)} \left({n \atop k}\right),\)
where \(v=n/k\), and \(G\in (0,1)\) is the unique solution to \(G = v e^{G-v}\). Relative error is bounded by about \(0.066/n\).
Unimodality
For fixed \(n\), \(\left\{{n \atop k}\right\}\) is unimodal, that is, the sequence increases and then decreases. The maximum is attained for at most two consecutive values of k. That is, there is an integer \(k_n\) such that
\(\left\{{n \atop 1}\right\} < \left\{{n \atop 2}\right\} < \cdots < \left\{{n \atop k_n}\right\} \geq \left\{{n \atop k_n+1}\right\} > \cdots > \left\{{n \atop n}\right\}.\)
Looking at the table of values above, the first few values for \(k_n\) are \(0, 1, 1, 2, 2, 3, 3, 4, 4, 4, 5, \ldots\)
When \(n\) is large
\(k_n \underset{n\to\infty}{\sim} \frac{n}{\log n},\)
and the maximum value of the Stirling number can be approximated with
\(\log \left\{{n \atop k_n}\right\} = n\log n - n \log\log n - n + O(n \log\log n / \log n).\)
Zvino iwe Hapana calculator inogadzirisa iyi imwe, asi mapepa ayo anogona kuongororwa. Tsananguro:
Mubhadharo wakasununguka unowedzera mazita ezvidzidzo, zvinyorwa zvezvidzidzo zvawakati wazvigadzirira, zvidzidzo zvawave uchizvigadzirisa, uye mudzidzisi waungabvunza nezvechidzidzo ichi. Maths inowanikwa kune vese, vasiri vadzidzi kana vadzidzi. Kuwana mazita ezvidzidzo zvinodiwa kunogona kuitwa pawebsite ye Maths.
Kutanga KupindaMazita anoshandiswa pano
Tinya chero chiratidzo kuti uone chirevo chakazara, vhidhiyo, uye kuti chii chinoreva chero chiratidzo.
Mabvunzo vanhu vanobvunza
Permutation or combination?
Ask whether order matters. A lock code is a permutation (order matters); a hand of cards is a combination (it does not).
What is a graph in this sense?
Dots (vertices) joined by lines (edges), not a plot. Road maps, social networks and molecules are graphs; questions like "is there a route" and "how few colours" are graph theory.
Zvimwe zvenyaya iyi zvakashandurwa kubva Wikipedia (CC BY-SA 4.0). Condensed uye re-akaratidza pano; zvikanganiso ndedu.
More in Combinatorics & Graph Theory
The counting principlesPigeonhole principle and inclusion, exclusionBinomial coefficients and Pascal's triangleRecurrences and generating functionsGraphs: vertices, edges, degreesPaths, cycles, trees, Euler and HamiltonColouring and planar graphs