互相关和相关问题相关系数 [英] A question on cross-correlation & correlation coefficient

查看:489
本文介绍了互相关和相关问题相关系数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可能重复:
Matlab互相关与相关系数问题

Possible Duplicate:
Matlab Cross correlation vs Correlation Coefficient question

当我在MATLAB中交叉关联2个数据集ab(每个长73点)并将其绘制图形时,它看起来像是一个具有145个点的三角形.当我绘制互相关输出范围为+/- 1时,我在相关系数和三角形图之间感到困惑.

When I cross correlate 2 data sets a and b (each 73 points long) in MATLAB and graph it, it appears like a triangle with 145 points. I'm confused between the correlation coefficient and the triangle-like graph when I plot the cross correlation output which ranges from +/- 1.

推荐答案

我认真地认为您需要阅读更多有关互相关函数的信息.统计书中的相关系数,因为您的困惑比与MATLAB的相关更根本.除非您知道要处理的内容,否则即使您正确地编写了程序,也无法理解MATLAB所提供的功能.

I seriously think you need to read up more on cross-correlation functions & correlation coefficient from a statistics book, because your confusion here is more fundamental than related to MATLAB. Unless you know what you're dealing with, you cannot make sense of what MATLAB gives you, even if you get the program right.

这是互相关中的操作.如下考虑数据AB

Here is what you do in a cross correlation. Consider data A and B as follows

    A                   B

    x                   
x   |       x           x   
|   |       |       x   |   
|   |   x   |       |   |   x
|   |   |   |       |   |   |
---------------     -----------
0   1   2   3       0   1   2 

然后拿B并将其一直滑到最后,以使B的最后一个点和A的第一个点对齐:

You then take B and slide it all the way to the end, so that the last point of B and the first point of A are aligned:

                x                   
            x   |       x 
            |   |       |   
            |   |   x   |       
            |   |   |   |
----x---x------------------
   -2  -1   0   1   2   3

        x   
    x   |   
    |   |   x
    |   |   |
----------------x---x---x--
   -2  -1   0   1   2   3

在数据不存在的地方填充零,例如,在这种情况下,B超出0,而A则在0之前.然后将它们逐点相乘并相加,将0 + 0 + 3 + 0 + 0 + 0 = 3作为第一个点互相关.

You fill in zeros where ever the data does not exist i.e., in this case, B beyond 0 and A before 0. Then you multiply them point wise and add, giving 0 + 0 + 3 + 0 + 0 + 0 = 3 as your first point in the cross-correlation.

然后向右滑动B一步并重复

Then you slide B one step to the right and repeat

            x                   
        x   |       x 
        |   |       |   
        |   |   x   |       
        |   |   |   |
----x------------------
   -1   0   1   2   3

        x   
    x   |   
    |   |   x
    |   |   |
----------------x---x--
   -1   0   1   2   3

给出0 + 9 + 4 + 0 + 0 = 13作为互相关中的第二点.一直这样做,直到将B一直滑到A的另一端.

giving 0 + 9 + 4 + 0 + 0 = 13 as the second point in the cross-correlation. You keep doing this till you slide B all the way to the other end of A.

结果向量为length(A)+length(B)-1,-1是因为我们从0的重叠处开始,所以它少了1个点.因此,在这里您应该在互相关中获得3 + 4 - 1=6点,在您的情况下,您应该获得73 + 73 -1 = 145点.

The resulting vector is length(A)+length(B)-1, the -1 being because we started with an overlap at 0, so it's one point less. So here you should get 3 + 4 - 1=6 points in the cross-correlation and in your case, you should get 73 + 73 -1 = 145 points.

如您所见,互相关矢量在任何点的值都不必在±1之内.当两个数据向量最相似"时,互相关具有最大值.峰值从零开始的偏移"表示两个数据集之间的滞后".

As you can see, the value of the cross-correlation vector at any point, need not be within ±1. The cross-correlation has a maximum when the two data vectors are "most alike". The "offset" of the peak from zero gives an indication of the "lag" between the two datasets.

相关系数(我假设是Pearson的)只是定义为

The correlation coefficient (I'm assuming Pearson's) is a mere number defined as

            Covariance(A,B)
r = --------------------------------
    ________________________________
  \|Covariance(A,A)*Covariance(B,B)

其中Covariance(A,A)更好地称为Variance(A).此数量的范围可以从-11(至于为什么它必须在±1之间,请查找

where Covariance(A,A) is better known as Variance(A). This is a quantity that can range from -1 to 1 (as for why it has to be between ±1, look up Cauchy-Schwartz inequality)

虽然可以肯定地计算出数据点不相等的两个数据向量的互相关,但不能计算它们的相关系数.协方差的概念是对两个变量/数据集如何一起更改的一种度量,并且没有为不相等的数据集定义.

While you can most certainly calculate the cross-correlation of two data vectors with unequal data points, you cannot compute their correlation coefficient. The notion of covariance is a measure of how two variables/datasets change together and is not defined for unequal datasets.

这篇关于互相关和相关问题相关系数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆