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: difference between xcorr and crosscorr?
Replies: 9   Last Post: Aug 9, 2017 9:57 AM

Advanced Search

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

Posts: 26
Registered: 3/5/10
Re: difference between xcorr and crosscorr?
Posted: Oct 18, 2012 11:55 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply


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.


"Iris Ehlert" wrote in message <jgjbe9$biq$>...
> 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.

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.