LINE Solver
MATLAB API documentation
Loading...
Searching...
No Matches
moment_binotrans.m
1function y = moment_binotrans(x)
2% y = moment_binotrans(x)
3%
4% Binomial transform of the sequence x_0,x_1,...,x_n into y_0,y_1,...,y_n,
5%
6% y_n = sum_{k=0}^{n} (-1)^(n-k) * nchoosek(n,k) * x_k
7%
8% Applied to a moment sequence m_i = E[X^i] it returns the moments of the
9% unit downshift, y_i = E[(X-1)^i]. It is not an involution: its inverse is
10% moment_binotransinv, the unsigned transform.
11%
12% Input:
13% x: vector of length n+1 holding x_0,...,x_n, i.e. x(i) is the element of
14% order i-1
15%
16% Output:
17% y: vector of length n+1 holding y_0,...,y_n, with the same orientation
18% as x
19%
20% Reference:
21% A. Heindl and A. van de Liefvoort. Moment conversions for discrete
22% distributions. PMCCS, 2003, eq. (8).
23%
24% Example:
25% y = moment_binotrans([1,2,5,15])
26
27xcol = x(:);
28n = length(xcol)-1;
29y = zeros(n+1,1);
30for i = 0:n
31 for k = 0:i
32 y(i+1) = y(i+1) + (-1)^(i-k) * nchoosek(i,k) * xcol(k+1);
33 end
34end
35if isrow(x)
36 y = y.';
37end
38end