Suvarna Garge (Editor)

Stirling numbers of the second kind

Updated on
Edit
Like
Comment
Share on FacebookTweet on TwitterShare on LinkedInShare on Reddit
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 { n k } . Stirling numbers of the second kind occur in the field of mathematics called combinatorics and the study of partitions.

Contents

Stirling numbers of the second kind are one of two kinds of Stirling numbers, the other kind being called Stirling numbers of the first kind (or Stirling cycle numbers). Mutually inverse (finite or infinite) triangular matrices can be formed from the Stirling numbers of each kind according to the parameters n, k.

Definition

The Stirling numbers of the second kind, written S ( n , k ) or { n k } 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,

{ n n } = 1 and for n 1 , { n 1 } = 1

as 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. They can be calculated using the following explicit formula:

{ n k } = 1 k ! j = 0 k ( 1 ) k j ( k j ) j n .

Notation

Various notations have been used for Stirling numbers of the second kind. The brace notation { n k } 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). However, 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.

Bell numbers

The sum over the values for k of the Stirling numbers of the second kind, gives us

B n = k = 0 n { n k }

the nth Bell number, that is the total number of partitions of a set with n members.

If we let

( x ) n = x ( x 1 ) ( x 2 ) ( x n + 1 )

(in particular, (x)0 = 1 because it is an empty product) be the falling factorial, we can characterize the Stirling numbers of the second kind by

k = 0 n { n k } ( x ) k = x n .

Analogously, the ordered Bell numbers can be computed from the Stirling numbers of the second kind as

a n = k = 0 n k ! { n k }

Table of values

Below is a triangular array of values for the Stirling numbers of the second kind (sequence A008277 in the OEIS):

As with the binomial coefficients, this table could be extended to k > n, but those entries would all be 0.

Recurrence relation

Stirling numbers of the second kind obey the recurrence relation

{ n + 1 k } = k { n k } + { n k 1 }

for k > 0 with initial conditions

{ 0 0 } = 1  and  { n 0 } = { 0 n } = 0

for n > 0.

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 understand 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

{ n k 1 }

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 { n k }

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.

Some more recurrences are as follows:

{ n + 1 k + 1 } = j = k n ( n j ) { j k } , { n + 1 k + 1 } = j = k n ( k + 1 ) n j { j k } , { n + k + 1 k } = j = 0 k j { n + j j } .

Lower and upper bounds

If n 2 and 1 k n 1 , then

L ( n , k ) { n k } U ( n , k )

where

L ( n , k ) = 1 2 ( k 2 + k + 2 ) k n k 1 1

and

U ( n , k ) = 1 2 ( n k ) k n k .

Maximum

For fixed n , { n k } has a single maximum, which is attained for at most two consecutive values of k. That is, there is an integer K n such that

{ n 1 } < { n 2 } < < { n K n } , { n K n } { n K n + 1 } > > { n n } .

When n is large

K n n log n ,

and the maximum value of the Stirling number of second kind is

log { n K n } = n log n n log log n n + O ( n log log n / log n ) .

Parity

The parity of a Stirling number of the second kind is equal to the parity of a related binomial coefficient:

{ n k } ( z w )   ( mod 2 ) , where z = n k + 1 2 ,   w = k 1 2 .

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:

A :   i A 2 i = n k , B :   j B 2 j = k 1 2 .

One can mimic a bitwise AND operation by intersecting these two sets:

{ n k } mod 2 = { 0 , A B ; 1 , A B = ;

to obtain the parity of a Stirling number of the second kind in O(1) time. In pseudocode:

{ n k } mod 2 := [ ( ( n k )   &   ( ( k 1 ) d i v 2 ) ) = 0 ] ;

where [ b ] is the Iverson bracket.

Simple identities

Some simple identities include

{ n n 1 } = ( 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

{ n 2 } = 2 n 1 1.

To see this, first note that there are 2 n ordered pairs of complementary subsets A and B. In one case, A is empty, and in another B is empty, so 2 n − 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.

{ n 2 } = 1 1 ( 2 n 1 1 n 1 ) 0 ! { n 3 } = 1 1 ( 3 n 1 2 n 1 ) 1 2 ( 3 n 1 1 n 1 ) 1 ! { n 4 } = 1 1 ( 4 n 1 3 n 1 ) 2 2 ( 4 n 1 2 n 1 ) + 1 3 ( 4 n 1 1 n 1 ) 2 ! { n 5 } = 1 1 ( 5 n 1 4 n 1 ) 3 2 ( 5 n 1 3 n 1 ) + 3 3 ( 5 n 1 2 n 1 ) 1 4 ( 5 n 1 1 n 1 ) 3 !    

Explicit formula

The Stirling numbers of the second kind are given by the explicit formula:

{ n k } = j = 1 k ( 1 ) k j j n 1 ( j 1 ) ! ( k j ) ! = 1 k ! j = 0 k ( 1 ) k j ( k j ) j n .

This formula is a special case of the kth forward difference of the monomial x n evaluated at x = 0:

Δ k x n = j = 0 k ( 1 ) k j ( k 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 ) = k = 0 m ( 1 ) k k ! k + 1 { m k } .

Generating functions

For a fixed integer n, generating functions for the Stirling numbers of the second kind { n 0 } , { n 1 } , are given by

k = 0 n { n k } ( x ) k = x n , k = 0 n { n k } x k = T n ( x ) ,

where T n ( x ) are Touchard polynomials.

For a fixed integer k, the Stirling numbers of the second kind { 0 k } , { 1 k } , have rational generating functions:

n = 0 { n k } x n k = r = 1 k 1 1 r x , n = 0 { n k } x n + 1 = 1 ( k + 1 ) ! ( 1 x k + 1 )

and an exponential generating function:

n = 0 { n k } x n n ! = ( e x 1 ) k k ! .

Note that { n k } = 0 for n < k .

A mixed bivariate generating function (exponential in x and ordinary in y) for the Stirling numbers of the second kind is

n , k = 0 { n k } x n n ! y k = n = 0 T n ( y ) x n n ! = e y ( e x 1 ) .

Asymptotic approximation

For fixed value of k , the asymptotic value of the Stirling numbers of the second kind is given by

{ n k } k n k ! .

On the other side, for n and k o ( n ) ,

{ n n k } ( n k ) 2 k 2 k k ! ( 1 + 1 3 2 k 2 + k n k + 1 18 4 k 4 k 2 3 k ( n k ) 2 + ) .

Uniformly valid approximation also exist

{ n k } n k n ( 1 G )   G k   ( v G ) n k ( n k e ) n k ( n k ) k , 1 < k < n

where G = W 0 ( v e v ) , v = n / k ,   W 0 ( z ) is main branch of Lambert W function. Relative error is bounded by about 0.06 / n .

Moments of the Poisson distribution

If X is a random variable with a Poisson distribution with expected value λ, then its nth moment is

E ( X n ) = k = 1 n { n k } λ k .

In particular, the nth moment of the Poisson distribution with expected value 1 is precisely the number of partitions of a set of size n, i.e., it is the nth Bell number (this fact is Dobinski's formula).

Moments of fixed points of random permutations

Let the random variable X be the number of fixed points of a uniformly distributed random permutation of a finite set of size m. Then the nth moment of X is

E ( X n ) = k = 1 m { n k } .

Note: The upper bound of summation is m, not n.

In other words, the nth moment of this probability distribution is the number of partitions of a set of size n into no more than m parts. This is proved in the article on random permutation statistics, although the notation is a bit different.

Rhyming schemes

The Stirling numbers of the second kind can represent the total number of rhyme schemes for a poem of n lines. S ( n , k ) gives the number of possible rhyming schemes for n lines using k unique rhyming syllables. As an example, for a poem of 3 lines, there is 1 rhyme scheme using just one rhyme (aaa), 3 rhyme schemes using two rhymes (aab, aba, abb), and 1 rhyme scheme using three rhymes (abc).

Associated Stirling numbers of the second kind

An r-associated Stirling number of the second kind is the number of ways to partition a set of n objects into k subsets, with each subset containing at least r elements. It is denoted by S r ( n , k ) and obeys the recurrence relation

S r ( n + 1 , k ) = k   S r ( n , k ) + ( n r 1 ) S r ( n r + 1 , k 1 )

The 2-associated numbers (sequence A008299 in the OEIS) appear elsewhere as "Ward numbers" and as the magnitudes of the coefficients of Mahler polynomials.

Reduced Stirling numbers of the second kind

Denote the n objects to partition by the integers 1, 2, ..., n. Define the reduced Stirling numbers of the second kind, denoted S d ( n , k ) , to be the number of ways to partition the integers 1, 2, ..., n into k nonempty subsets such that all elements in each subset have pairwise distance at least d. That is, for any integers i and j in a given subset, it is required that | i j | d . It has been shown that these numbers satisfy

S d ( n , k ) = S ( n d + 1 , k d + 1 ) , n k d

(hence the name "reduced"). Observe (both by definition and by the reduction formula), that S 1 ( n , k ) = S ( n , k ) , the familiar Stirling numbers of the second kind.

References

Stirling numbers of the second kind Wikipedia