LINE Solver
MATLAB API documentation
Loading...
Searching...
No Matches
MomsFromHankelMoms.m
1% m = MomsFromHankelMoms(hm)
2%
3% Returns the raw moments given the Hankel moments.
4%
5% The raw moments are: `m_i=E(\mathcal{X}^i)`
6%
7% The ith Hankel moment is the determinant of matrix
8% `\Delta_{i/2}`, if i is even,
9% and it is the determinant of `\Delta^{(1)}_{(i+1)/2}`,
10% if i is odd. For the definition of matrices `\Delta`
11% and `\Delta^{(1)}` see [1]_.
12%
13% Parameters
14% ----------
15% hm : vector of doubles
16% The list of Hankel moments (starting with the first
17% moment)
18%
19% Returns
20% -------
21% m : vector of doubles
22% The list of raw moments
23%
24% References
25% ----------
26% .. [1] http://en.wikipedia.org/wiki/Stieltjes_moment_problem
27
28function m=MomsFromHankelMoms(hm)
29
30 m = hm(1);
31 for i=1:length(hm)-1
32 if rem(i,2) == 0
33 N = i/2 + 1;
34 H = hankel(m(1:N), [m(N:2*N-2),0]);
35 else
36 N = (i+1) / 2 + 1;
37 H = hankel([1,m(1:N-1)], [m(N-1:2*N-3),0]);
38 end
39 h = hm(i+1);
40 rH = H(1:N-1,:);
41 for j=0:N-1
42 rHd = rH;
43 rHd(:,j+1) = [];
44 cofactor = (-1)^(N+j-1) * det(rHd);
45 if j<N-1
46 h = h - cofactor * H(N,j+1);
47 else
48 m = [m h/cofactor];
49 end
50 end
51 end
52end
53