1function kappa = moment_joint_cumulant_from_raw(m)
2% kappa = moment_joint_cumulant_from_raw(m)
4% Converts the joint power (raw) moments of a random vector (N_1,...,N_d) into
5% its joint cumulants, the coefficients of the joint cumulant generating
8% log E[exp(s_1 N_1 + ... + s_d N_d)] =
sum_(a ~= 0) kappa_a prod_j
11% They obey the multivariate exponential formula, equivalently the
12% Leonov-Shiryaev partition formula. With j the first dimension in which the
13% multi-index a
is nonzero,
15% m_a =
sum_(0<b<=a) prod_l nchoosek(a_l-[l=j], b_l-[l=j]) kappa_b m_(a-b)
17% which isolates kappa_a because the b = a term has unit coefficient and
18% m_0 = 1. Unlike every other conversion in the house, this one does not
factor
19% into a product of univariate transforms: the cumulant of multi-order (1,1)
is
20% the covariance, which mixes the dimensions.
23% m: array of size (n_1+1)x...x(n_d+1) holding the joint power moments, with
27% kappa: array of the same size holding the joint cumulants, element 1 being
31% kappa = moment_joint_cumulant_from_raw(m); % kappa(2,2)
is the covariance
34% V.
P. Leonov and A. N. Shiryaev. On a method of calculation of
35% semi-invariants. Theory of Probability and its Applications,
38sz = moment_tensorsize(m);
41stride = cumprod([1, sz(1:end-1)]);
42mv = reshape(m, [], 1);
51 if any(b > 1) && ~isequal(b,a) && b(j) > 1
54 alpha = a(l) - 1 - (l == j);
55 beta = b(l) - 1 - (l == j);
56 c = c * nchoosek(alpha, beta);
59 acc = acc + c * kv(1 + sum((b-1).*stride)) * mv(1 + sum((a-b).*stride));
70 kv(ia) = mv(ia) - acc;
80kappa = reshape(kv, size(m));