LINE Solver
MATLAB API documentation
Loading...
Searching...
No Matches
moment_central_from_raw.m
1function mc = moment_central_from_raw(m)
2% mc = moment_central_from_raw(m)
3%
4% Converts the power (raw) moments m_n = E[N^n] of a random variable N into
5% the central moments m_n^c = E[(N-m_1)^n] by means of the binomial transform
6% in the variation that involves the mean m_1,
7%
8% m_n^c = sum_{k=0}^{n} (-1)^(n-k) * nchoosek(n,k) * m_k * m_1^(n-k)
9%
10% The conversion also holds for continuous random variables.
11%
12% Input:
13% m: vector of length n+1 holding m_0,...,m_n, i.e. m(i) is the moment of
14% order i-1 and m(1) = m_0 = 1. At least the mean m_1 must be given,
15% hence n >= 1
16%
17% Output:
18% mc: vector of length n+1 holding m_0^c,...,m_n^c, with the same
19% orientation as m. By construction m_0^c = 1 and m_1^c = 0
20%
21% Reference:
22% A. Heindl and A. van de Liefvoort. Moment conversions for discrete
23% distributions. PMCCS, 2003, Section 4.
24%
25% Example:
26% mc = moment_central_from_raw([1,2,6,22])
27
28mcol = m(:);
29n = length(mcol)-1;
30if n < 1
31 line_error(mfilename,'The mean m_1 is required for this conversion, hence m must have at least 2 elements.');
32end
33m1 = mcol(2);
34mc = zeros(n+1,1);
35for i = 0:n
36 for k = 0:i
37 mc(i+1) = mc(i+1) + (-1)^(i-k) * nchoosek(i,k) * mcol(k+1) * m1^(i-k);
38 end
39end
40if isrow(m)
41 mc = mc.';
42end
43end
Definition Station.m:245