LINE Solver
MATLAB API documentation
Loading...
Searching...
No Matches
LagkJointMomentsFromTrace.m
1% Nm = LagkJointMomentsFromTrace(trace, K, L)
2%
3% Returns the lag-L joint moments of a trace.
4%
5% It is computed as `Nm_{i,j}=\frac{1}{N-L}\sum_{k=0}^{N-L} x_k^i x_{k+L}^j`.
6%
7% Parameters
8% ----------
9% trace : vector of doubles
10% The trace data
11% K : int
12% The joint moments are computed up to order K
13% L : int, optional
14% The lag-L joint moments are computed.
15% The default value is 1.
16%
17% Returns
18% -------
19% Nm : matrix, shape (K,K)
20% The matrix of joint moments, starting from moment 0
21
22function Nm = LagkJointMomentsFromTrace (trace, K, L)
23
24 if nargin<3
25 L = 1;
26 end
27 if nargin<2
28 K = 3;
29 end
30
31 Nm = zeros(K,K);
32 for i=0:K
33 for j=0:K
34 Nm(i+1,j+1) = dot(trace(1:end-L).^i, trace(L+1:end).^j) / (length(trace)-L);
35 end
36 end
37end