Search All of the Math Forum:

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

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

Topic: difference between xcorr and crosscorr?
Replies: 9   Last Post: Aug 9, 2017 9:57 AM

 Messages: [ Previous | Next ]
 Rick Posts: 26 Registered: 3/5/10
Re: difference between xcorr and crosscorr?
Posted: Oct 18, 2012 11:55 AM

Iris,

The distinction between the 2 functions is likely due to the intended audience.

The CROSSCORR in the Econometrics Toolbox is designed for financial/economic users, wherein the standard approach is to remove the mean from each series. For example, see Box and Jenkins. (In fact, the usual way to compute the sample variance of any series is to first extract the mean.)

In economic applications, the usual approach is also to normalize by the product of the sample standard deviations of each series x(t) and y(t).

For a sample auto-correlation function (ACF), as computed by the Econometrics Toolbox function AUTOCORR, this has the added effect of producing an ACF whose value at lag zero is unity, since x(t) = y(t).

However, for CROSSCORR, the scaling does not ensure the XCF at lag zero is one.

Also, as mentioned in another response, for two series x and y, XCORR and CROSSCORR will compute the same XCF function for N lags (to within numerical precision) for calls like this:

c = xcorr(x - mean(x), y - mean(y), N, 'coeff');
C = crosscorr(y, x, N);

As far as which is correct, they're both correct ... it just depends on what you want.

HTH,
-Rick

"Iris Ehlert" wrote in message <jgjbe9\$biq\$1@newscl01ah.mathworks.com>...
> Dear members of mathworks,
>
> I did a cross correlation for two time series both with xcorr.m and crosscorr.m. The results are completely different, which definitely shouldn't be the case, since the documentation for both functions describe the same.
>
> So I would really, really appreciate it, if you could tell me why this happens.
>
> I used the same lags, same series - so it is really the function itself causing the different results.
>
> Cheers,
> ie.

Date Subject Author
2/4/12 Iris Ehlert
2/4/12 ImageAnalyst
2/7/12 Steven Lord
10/17/12 Tikkuhirvi Tietavainen
8/9/17 Greg Heath
10/18/12 Rick
7/11/17 E. Natasha Stavros
7/12/17 Rick
11/27/12 Ye Gao
11/29/12 Greg Heath