The Math Forum

Search All of the Math Forum:

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

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

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

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 ]

Posts: 32
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$>...
> 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:


%cross - correlation in lag =2, so I would have:


covariance = [(-1.7596 - mean(x))*(-1.7596 - mean(y))+(0.2370-mean(y))*(0.2370-mean(x))]/3


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]

© The Math Forum at NCTM 1994-2018. All Rights Reserved.