In reviewing questions and material on xcorr, it appears to be that for autocorrelation or cross-corelation coefficients, most responses suggest using the 'coef' option in xcorr. While this does give you a value between -1 and 1, I am not sure why this option is calculated with as xcorr(a,b)/(norm(a)*norm(b)) where a and b are column vectors, in most cases I would think an unbiased correlation should be used?
In my limited understanding, it seems the correlation values should be unbiased, then normalized…
For example autocorrelation, xcorr(a,'unbiased')./var(a),
To illustrate my point, if I autocorrelate a sine function, I would expect the lagged correlation coefficient to vary between 1 and -1 every time the cycle re-alignes itself. But the 'coef' option consistently deceases the correlation coefficient with lag. I realized this is because of how it is calculated, but I don't understand why it is calculated this way? Shouldn't the unbiased approach be used?
A simple example to illustrate this question: t=0:500; n=length(t); ts=5*sin(2*pi*(t./12)); lags=-250:250; test1=xcov(ts,250,'coef'); test2=xcov(ts,250,'unbiased')./var(ts);
figure; plot(t,ts); xlabel('time'); ylabel('amplitude'); figure; plot(lags,test2,'r'); hold on; plot(lags,test1);
Best Answer