Stirling number of the second kind is the number of ways to partition a set of n objects into k nonempty subsets and is denoted by S(k,i). Stirling numbers of the second kind occur in the field of mathematics called combinatorics and the study of partitions. In short words, it is the number of ways to distribute k distinguishable elements into I indistinguishable receptacles with no receptacle empty.
Stirling numbers of the second kind is one of two kinds of Stirling numbers, the other kind being called Stirling numbers of the first kind, are the coefficients of powers of x in the polynomials [eg. Q(x)=(x1)*(x2)*...*(xn)].
It is called as it after the British mathematician James Stirling (16921770).
In statistics, it is used in calculate (deriving) raw moments (noncentral) in some discrete distributions as Geometric, Binomial, Negative Binomial, and Poisson, in a way that simplify the usual method of deriving raw moments of higher order of an integervalued random variable by differentiate the generating function as many times as the order of the moment requires.
They can be calculated using the following explicit formula:
S(k,i) = 1/i! * i=0_Sum_r * (1)^(ri) * rCi * i^k
where 0 =< r =< k and k are any nonnegative integer. rCi, combination i from r.
Here we develp the mfile to generate the Stirling number of the second kind. It is considered more informative than the previous mfiles generated before in this MCFEX such as by Nikollaus Lorrell (13112006) and Luca (11032011). This for it gives, not only a specific Stirling number of second kind, but also (by default) the complete k partition.
Syntax: function x = nstir2k(a,b)
Inputs:
a  set of n objects
b  i nonempty subsets
Outputs:
x  Stirling number(s) of the second kind
