Search All of the Math Forum:
Views expressed in these public forums are not endorsed by
Drexel University or The Math Forum.


condor
Posts:
30
Registered:
3/2/10


Re: crosscorr(x,y)  strange value!
Posted:
Mar 23, 2012 10:35 AM


"condor" wrote in message <jkgoqu$g1o$1@newscl01ah.mathworks.com>... > Doing this: > > >> x = randn(10, 1); > >> y = lagmatrix(x, 4); > >> y(isnan(y)) = 0; > >> crosscorr(x, y) > > > I was expecting to see a correlation coefficient = 1 in lag = 4, while the correlation is just 0.66. > Creating a delayed version of the same vector, when the lag = 4 I have the same exact numbers! I am suspecting that it keeps always the same mean and std deviation for all the lags. > > Am I right?
Ok I think I was right ... I create an example:
x=[1.7596;0.2370;0.1622;0.1701]; y=[0;0;1.7596;0.2370];
%cross  correlation in lag =2, so I would have:
x=[1.7596;0.2370]; y=[1.7596;0.2370];
covariance = [(1.7596  mean(x))*(1.7596  mean(y))+(0.2370mean(y))*(0.2370mean(x))]/3 x_StandardDeviation=std(x); y_StandardDeviation=std(y);
CrossCorrelationLag2=covariance/(x_StandardDeviation*y_StandardDeviation)
This seems to be correct! However: a) I understand the it always keep, for all the lags, this denominator: (x_StandardDeviation*y_StandardDeviation) ... maybe in order to reduce the possibility to get false correlation caused by biasing estimates with larger lags, b) BUT why dividing the covariance by 3 (N1=41=3) when I am calculating it just for 2 elements? This shouldn't be a covariance anymore...
Did I make any mistake?



