1function S = moment_stirling2(n)
2% S = moment_stirling2(n)
4% Triangle of
the Stirling numbers of
the second kind S(i,j), implicitly
5% defined by
the expansion of a power into falling factorials
7% x^i = sum_{j=0}^{i} S(i,j) x(x-1)(x-2)...(x-j+1)
9% and computed from
the recursion
11% S(i,j) = j*S(i-1,j) + S(i-1,j-1) for j > 0
12% S(0,0) = 1, S(i,0) = 0 for i > 0
14% These numbers are
the coefficients that convert factorial moments back into
18% n: maximum order (n >= 0)
21% S: (n+1)x(n+1) matrix with S(i+1,j+1) = S(i,j) in
the 0-based notation of
22%
the reference. Entries with j > i are zero.
25% A. Heindl and A. van de Liefvoort. Moment conversions for discrete
26% distributions. PMCCS, 2003, eq. (11).
29% S = moment_stirling2(3)
31if ~isscalar(n) || n < 0 || n ~= round(n)
32 line_error(mfilename,'The maximum order n must be a nonnegative integer.');
38 S(i+1,j+1) = j*S(i,j+1) + S(i,j);