LINE Solver
MATLAB API documentation
Loading...
Searching...
No Matches
MomsFromFactorialMoms.m
1% m = MomsFromFactorialMoms(fm)
2%
3% Returns the raw moments given the factorial moments.
4%
5% The raw moments are: `m_i=E(\mathcal{X}^i)`
6%
7% The factorial moments are: `f_i=E(\mathcal{X}(\mathcal{X}-1)\cdots(\mathcal{X}-i+1))`
8%
9% Parameters
10% ----------
11% fm : vector of doubles
12% The list of factorial moments (starting with the first
13% moment)
14%
15% Returns
16% -------
17% m : vector of doubles
18% The list of raw moments
19%
20% References
21% ----------
22% http://en.wikipedia.org/wiki/Factorial_moment
23
24function m=MomsFromFactorialMoms(fm)
25
26 n=length(fm);
27 m=zeros(1,n);
28 m(1)=fm(1);
29
30 for i=2:n
31 eh=-poly(0:i-1);
32 eh=eh(end-1:-1:2);
33 m(i)=fm(i)+eh*(m(1:i-1))';
34 end
35 m = reshape(m, size(fm));
36end