1function T = moment_housematrix(edge, n)
2% T = moment_housematrix(edge, n)
4% Conversion matrix of one edge of the house of moments.
6% The edge
is returned as a linear
map on the moment subspace {m_0 = 1}. Four
7% edges (the Lah pair and the shifted-binomial pair) pin their zeroth output to
8% 1 rather than propagating element 0, so as maps of the whole space they are
9% affine. Here the offset
is folded into
column 0, which
is empty
for those
10% edges, making every edge a genuine matrix. On a moment vector, whose element
11% 0
is 1 by definition, the two agree. This
is also what makes those edges
12% usable dimension by dimension in the joint conversions.
15% edge: one of
'factorial_from_raw',
'raw_from_factorial',
16%
'upfactorial_from_raw',
'raw_from_upfactorial',
17%
'binomial_from_factorial',
'factorial_from_binomial',
18%
'negbinomial_from_upfactorial',
'upfactorial_from_negbinomial',
19%
'factorial_from_upfactorial',
'upfactorial_from_factorial',
20%
'negbinomial_from_binomial',
'binomial_from_negbinomial',
21%
'binomial_from_tail',
'tail_from_binomial'
22% n: maximum order of the mode (n >= 0)
25% T: (n+1)x(n+1) conversion matrix
28% T = moment_housematrix(
'factorial_from_raw', 4);
31% A. Heindl and A. van de Liefvoort. Moment conversions
for discrete
32% distributions. PMCCS, 2003.
34if ~isscalar(n) || n < 0 || n ~= round(n)
35 line_error(mfilename,
'The maximum order n must be a nonnegative integer.');
38 case 'factorial_from_raw'
39 T = moment_stirling1(n);
40 case 'raw_from_factorial'
41 T = moment_stirling2(n);
42 case 'upfactorial_from_raw'
43 T = moment_stirlingcycle(n);
44 case 'raw_from_upfactorial'
45 S = moment_stirling2(n);
49 T(i+1,j+1) = (-1)^(i-j) * S(i+1,j+1);
52 case {
'binomial_from_factorial',
'negbinomial_from_upfactorial'}
53 T = diag(1 ./ factorial(0:n));
54 case {
'factorial_from_binomial',
'upfactorial_from_negbinomial'}
55 T = diag(factorial(0:n));
56 case {
'factorial_from_upfactorial',
'upfactorial_from_factorial'}
62 if strcmp(edge,
'upfactorial_from_factorial')
63 T(i+1,k+1) = L(i+1,k+1);
65 T(i+1,k+1) = (-1)^(i-k) * L(i+1,k+1);
69 case {
'negbinomial_from_binomial',
'binomial_from_negbinomial'}
74 c = nchoosek(i-1,k-1);
75 if strcmp(edge,
'negbinomial_from_binomial')
78 T(i+1,k+1) = (-1)^(i-k) * c;
82 case {
'binomial_from_tail',
'tail_from_binomial'}
87 c = nchoosek(k-1,i-1);
88 if strcmp(edge,
'binomial_from_tail')
91 T(i+1,k+1) = (-1)^(k-i) * c;
96 line_error(mfilename,sprintf('Unknown edge %s.',edge));