1
votes

I'm writing a program in C++ but using data from matlab involving Cross Correlation. I understand that when I do a correlation on 2 sets of data it gives me a single correlation coefficient number indicating if they are related. But I'm wanting to use Cross Correlation on the data series. When I run Cross Correlation on Matlab it gives me a lot of data and when plotted the plot looks like a triangle... I understand Correlation is supposed to be somewhere between +/- 1 but the data toward the tip of the triangle doesn't go up at the same time etc. Do I have a confusion with what Cross Correlation is giving me or is the data that Cross Correlation gives me actually correlation coefficients for each point s(t),p(t) for instance? Any help with clarifying is appreciated.

Edit 1 (after Phonon's Response)

My main question is: Is the data that I get when I cross correlate 2 data series the correlation coefficient for each point. For instance, (0,10) and (0,8); Is the data I'm getting the correlation coefficient of those 2 plots at x=0 ?

3
How are you computing the correlation?Oliver Charlesworth
xcorr but my main question is Is the data that I get when I cross correlate 2 data series the correlation coefficient for each point. For instance, (0,10) and (0,8); Is the data I'm getting the correlation coefficient of those 2 plots at x=0 ?user772225

3 Answers

2
votes

In Matlab xcorr(x,x) gives auto-correlation of signal x. It is not scaled, it's simply a vector of inner products of the signal with shifted versions of itself. In order to scale it, use xcorr(x,x,'coeff'). This command will scale your auto-correlation by signal's energy (in other words it will divide each coefficient by value of coefficient at zero lag). Note that when you're doing cross-correlation, xcorr(x,y'coeff'), you will not get a value of 1 and zero lag, because the scaling is performed differently. It will only be 1 if you're correlating a signal with itself (I wish SO supported math formulas so that I could write it out for you).

0
votes
0
votes

To be clear about several concepts.

  1. Cross-correlation vs. cross-covariance. The main difference is that cross-covariance normalize the data by subtracting the mean.

  2. cross-covariance vs. normalized cross-covariance. The later one is divided by the standard deviation of the the input.

  3. normalized cross-covariance and correlation coefficient. The later one is the special case of the former one at delay=0.