LINE Solver
MATLAB API documentation
Loading...
Searching...
No Matches
moment_stirlingcycle.m
1function sigma = moment_stirlingcycle(n)
2% sigma = moment_stirlingcycle(n)
3%
4% Triangle of the Stirling cycle numbers (unsigned Stirling numbers of the
5% first kind), sigma(i,j) = (-1)^(i-j) * s(i,j), obtained from the recursion
6%
7% sigma(i,j) = (i-1)*sigma(i-1,j) + sigma(i-1,j-1) for j > 0
8% sigma(0,0) = 1, sigma(i,0) = 0 for i > 0
9%
10% These numbers are the coefficients that convert power moments into
11% upward-factorial moments.
12%
13% Input:
14% n: maximum order (n >= 0)
15%
16% Output:
17% sigma: (n+1)x(n+1) matrix with sigma(i+1,j+1) = sigma(i,j) in the 0-based
18% notation of the reference. Entries with j > i are zero.
19%
20% Reference:
21% A. Heindl and A. van de Liefvoort. Moment conversions for discrete
22% distributions. PMCCS, 2003, eq. (12).
23%
24% Example:
25% sigma = moment_stirlingcycle(3)
26
27if ~isscalar(n) || n < 0 || n ~= round(n)
28 line_error(mfilename,'The maximum order n must be a nonnegative integer.');
29end
30sigma = zeros(n+1,n+1);
31sigma(1,1) = 1;
32for i = 1:n
33 for j = 1:i
34 sigma(i+1,j+1) = (i-1)*sigma(i,j+1) + sigma(i,j);
35 end
36end
37end
Definition Station.m:245