LINE Solver
MATLAB API documentation
Loading...
Searching...
No Matches
moment_joint_central_from_raw.m
1function mc = moment_joint_central_from_raw(m)
2% mc = moment_joint_central_from_raw(m)
3%
4% Converts the joint power (raw) moments of a random vector (N_1,...,N_d) into
5% the joint central moments mc_(i_1,...,i_d) = E[prod_j (N_j - E N_j)^(i_j)].
6%
7% The conversion is the multi-index binomial theorem, which is again separable
8% but with a different shift per dimension,
9%
10% mc_(i) = sum_(k<=i) prod_j (-1)^(i_j-k_j) nchoosek(i_j,k_j) mu_j^(i_j-k_j)
11% * m_(k)
12%
13% The means mu_j = m_(e_j) are read off the array itself, so every dimension
14% must carry at least the first order. The entry of multi-order e_j+e_l is the
15% covariance of N_j and N_l.
16%
17% Input:
18% m: array of size (n_1+1)x...x(n_d+1) holding the joint power moments, with
19% every n_j >= 1
20%
21% Output:
22% mc: array of the same size holding the joint central moments
23%
24% Example:
25% mc = moment_joint_central_from_raw(m);
26%
27% Reference:
28% A. Heindl and A. van de Liefvoort. Moment conversions for discrete
29% distributions. PMCCS, 2003, Section 4.
30
31sz = moment_tensorsize(m);
32d = numel(sz);
33if any(sz < 2)
34 line_error(mfilename,'The means m_(e_j) are required for this conversion, hence every dimension of m must have at least 2 elements.');
35end
36mu = zeros(1,d);
37stride = cumprod([1, sz(1:end-1)]);
38mv = reshape(m, [], 1);
39for j = 1:d
40 mu(j) = mv(1 + stride(j));
41end
42mc = moment_joint_central_from_raw_mean(m, mu);
43end