LINE Solver
MATLAB API documentation
Loading...
Searching...
No Matches
moment_stirling2.m
1function S = moment_stirling2(n)
2% S = moment_stirling2(n)
3%
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
6%
7% x^i = sum_{j=0}^{i} S(i,j) x(x-1)(x-2)...(x-j+1)
8%
9% and computed from the recursion
10%
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
13%
14% These numbers are the coefficients that convert factorial moments back into
15% power moments.
16%
17% Input:
18% n: maximum order (n >= 0)
19%
20% Output:
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.
23%
24% Reference:
25% A. Heindl and A. van de Liefvoort. Moment conversions for discrete
26% distributions. PMCCS, 2003, eq. (11).
27%
28% Example:
29% S = moment_stirling2(3)
30
31if ~isscalar(n) || n < 0 || n ~= round(n)
32 line_error(mfilename,'The maximum order n must be a nonnegative integer.');
33end
34S = zeros(n+1,n+1);
35S(1,1) = 1;
36for i = 1:n
37 for j = 1:i
38 S(i+1,j+1) = j*S(i,j+1) + S(i,j);
39 end
40end
41end
Definition Station.m:245