LINE Solver
MATLAB API documentation
Loading...
Searching...
No Matches
LagCorrelationsFromTrace.m
1% acf = LagCorrelationsFromTrace(trace, K)
2%
3% Returns the lag-k autocorrelation of a trace.
4%
5% Parameters
6% ----------
7% trace : vector of doubles
8% The trace data
9% K : int
10% The number of lags to compute
11%
12% Returns
13% -------
14% acf : column vector of doubles
15% The lag-k autocorrelation function of the trace up to
16% lag K
17
18function acf = LagCorrelationsFromTrace (trace, K)
19
20 if nargin<2
21 K = 3;
22 end
23
24 m = mean(trace);
25 v = var(trace);
26
27 acf = zeros(1,K);
28 for i=1:K
29 acf(i) = (dot(trace(1:end-i),trace(i+1:end)) / (length(trace)-i) - m^2) / v;
30 end
31end
32