LINE Solver
MATLAB API documentation
Loading...
Searching...
No Matches
moment_raw_from_cumulant.m
1function m = moment_raw_from_cumulant(kappa)
2% m = moment_raw_from_cumulant(kappa)
3%
4% Converts the cumulants kappa_n of a random variable X into its power (raw)
5% moments m_n = E[X^n], by running the exponential-formula recursion forward,
6%
7% m_n = sum_{k=1}^{n} nchoosek(n-1,k-1) * kappa_k * m_(n-k)
8%
9% with m_0 = 1. Equivalently m_n = sum_{pi in P(n)} prod_{B in pi} kappa_|B|
10% over the set partitions of {1,...,n}. Inverse of moment_cumulant_from_raw.
11%
12% Input:
13% kappa: vector of length n+1 holding kappa_0,...,kappa_n, i.e. kappa(i) is
14% the cumulant of order i-1. Element 1 is ignored, since kappa_0 = 0
15% carries no information
16%
17% Output:
18% m: vector of length n+1 holding m_0,...,m_n, with the same orientation as
19% kappa and m(1) = 1
20%
21% Example:
22% m = moment_raw_from_cumulant(moment_cumulant_from_raw([1, 2, 6, 22]));
23%
24% Reference:
25% V. P. Leonov and A. N. Shiryaev. On a method of calculation of
26% semi-invariants. Theory of Probability and its Applications,
27% 4(3):319-329, 1959.
28
29kcol = kappa(:);
30n = length(kcol)-1;
31m = zeros(n+1,1);
32m(1) = 1;
33for i = 1:n
34 acc = 0;
35 for k = 1:i
36 acc = acc + nchoosek(i-1,k-1) * kcol(k+1) * m(i-k+1);
37 end
38 m(i+1) = acc;
39end
40if isrow(kappa)
41 m = m.';
42end
43end