nstir2k

Stirling number(s) of the second kind.
317 Downloads
Updated 17 Oct 2012

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

Cite As

Antonio Trujillo-Ortiz (2024). nstir2k (https://www.mathworks.com/matlabcentral/fileexchange/38597-nstir2k), MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2010a
Compatible with any release
Platform Compatibility
Windows macOS Linux
Categories
Find more on Frequently-used Algorithms in Help Center and MATLAB Answers

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
Version Published Release Notes
1.1.0.0

It was added an appropriate format to cite this file.

1.0.0.0