计算两个数组之间相关性的高效算法 [英] Efficient algorithm to calculate Correlation between two Arrays
问题描述
我正在寻找一种算法来计算两个双精度数组之间的相关性。
I'm looking for an algorithm to calculate correlation between two array of doubles.
算法的名称是什么,如果可能,我需要c ++源代码
What are the names of the algorithms and I need c++ source code if it's possible.
通过关联,我的意思是数组中数据的相似性...
And by correlation I mean the similarity of data in the array...
例如:
Array1:1 2 3
Array2:2 3 5
Array1: 1 2 3 Array2: 2 3 5
应该具有比更高的相似性度量这2个数组:
should have a higher similarity measure than these 2 arrays:
Array1:1 2 3
Array2:9 8 15
Array1: 1 2 3 Array2: 9 8 15
推荐答案
您需要计算样本Pearson产品-时刻相关系数:以上公式建议了一种用于计算样本相关性的便捷单遍算法。编写一个循环以计算sum(xi),sum(yi),sum(xi ^ 2),sum(yi ^ 2)和sum(xi * yi)。然后将这些总和插入公式中。
You need to calculate the sample Pearson product-moment correlation coefficient: "The above formula suggests a convenient single-pass algorithm for calculating sample correlations". Write a loop to calculate sum(xi), sum(yi), sum(xi^2), sum(yi^2), and sum(xi*yi). Then insert these sums into the formula.
这篇关于计算两个数组之间相关性的高效算法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!