1function rho=trace_acf(S,lags)
5% Compute the autocorrelation function
for trace S at the lags specified in vector L
13if max(lags)>length(S)-2
14 warning(
'Lags are higher than the trace length, truncating the lags vector.');
15 lags = min(lags,length(S)-2);
16 lags(lags == length(S)-2) = [];
20 rho=xcorr(S-mean(S),max(lags),'coeff');
21 rho=rho((max(lags)+2):end);
24 %warning('trace_acf: signal processing toolbox not found, autocorrelation estimation may be slower than usual.');
26 acv = autocov(S-mean(S));
27 rho=acv(1+lags)'/acv(1);
30% rho = zeros(1,length(lags));
31% for ki=1:length(lags)
32% rho(ki)=(trace_joint(S,[0,lags(ki)],[1,1])-E1^2)/(E2-E1^2);