是否有等效于 Matlab 的二维相关系数的函数?我想在 2 个一维数组上使用它。 http://www.mathworks.com/help/toolbox/images/ref/corr2.html
编辑:我自己的实现
//Assume we have the length and averages of both arrays
//double a_average, b_average
double a_val =0;
double b_val = 0;
double a_sum = 0 ;
double b_sum = 0;
double a_stdev = 0;
double b_stdev = 0;
int size = a.length; // same as b's length
for (int i = 0 ; i < size ; i ++) {
a_val =(a[i]- a_average);
b_val =(b[i] -b_average);
a_sum += a_val;
b_sum += b_val;
a_stdev += Math.pow(a_val,2);
b_stdev += Math.pow(b_val,2);
}
double coefficient = ((a_sum *b_sum)/(a_stdev*b_stdev))
谢谢