Pearson相关系数用来衡量两个数据集合是否在一条线上面。其计算公式为:

一个具体的计算的例子:
X Y
1 2
2 5
3 6

而利用matlab计算:函数 corrcoef
例如:
help corrcoef
x = randn(30,4); % Uncorrelated
data
x(:,4) = sum(x,2); % Introduce correlation.
[r,p] = corrcoef(x) % Compute sample correlation and
p-values.
[i,j] = find(p<0.05); % Find significant
correlations.
[i,j]
%
Display their (row,col) indices.
r =
1.0000 -0.3566
0.1929 0.3457
-0.3566 1.0000
-0.1429
一个具体的计算的例子:
X Y
1 2
2 5
3 6

而利用matlab计算:函数 corrcoef
例如:
help corrcoef
x = randn(30,4);
x(:,4) = sum(x,2);
[r,p] = corrcoef(x)
[i,j] = find(p<0.05);
[i,j]
r =
