Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.matlab

Topic: crosscorr(x,y) --- strange value!
Replies: 2   Last Post: Aug 8, 2012 6:53 AM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
condor

Posts: 30
Registered: 3/2/10
Re: crosscorr(x,y) --- strange value!
Posted: Mar 23, 2012 10:35 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

"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.2370-mean(y))*(0.2370-mean(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 (N-1=4-1=3) when I am calculating it just for 2 elements? This shouldn't be a covariance anymore...

Did I make any mistake?



Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.