File Exchange

image thumbnail

nstir2k

version 1.1 (2.51 KB) by

Stirling number(s) of the second kind.

2 Downloads

Updated

View License

Stirling number of the second kind is the number of ways to partition a set of n objects into k non-empty 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)=(x-1)*(x-2)*...*(x-n)].

It is called as it after the British mathematician James Stirling (1692-1770).

In statistics, it is used in calculate (deriving) raw moments (non-central) 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 integer-valued 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)^(r-i) * rCi * i^k

where 0 =< r =< k and k are any non-negative integer. rCi, combination i from r.

Here we develp the m-file to generate the Stirling number of the second kind. It is considered more informative than the previous m-files generated before in this MCFEX such as by Nikollaus Lorrell (13-11-2006) and Luca (11-03-2011). 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 non-empty subsets

Outputs:
x - Stirling number(s) of the second kind

Comments and Ratings (1)

nstir2k(100 , 100) = -1.7403e+37
Should be equal to 1.

Updates

1.1

It was added an appropriate format to cite this file.

MATLAB Release
MATLAB 7.10 (R2010a)

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video