如何衡量两个系列数据之间的相似性?

发布于 2024-12-19 04:28:56 字数 298 浏览 1 评论 0原文

我需要找到两个数据数组之间的相似性度量。 您可以将相似性度量称为任何您想要的名称,差异、相关性或任何其他名称。

例如:

 1, 2, 3, 4, 5 < Series 1
 2, 3, 4, 5, 6 < Series 2

应该比这两个系列更加相似:

 1, 2, 3, 4, 5 < Series 1
 1, 1, 5, 8, 7 < Series 2

有什么建议吗?

有可用的源代码吗?

I need to find a similarity measurement between two arrays of data.
You can call similarity measurement whatever you want, difference, correlation or whatever.

For example:

 1, 2, 3, 4, 5 < Series 1
 2, 3, 4, 5, 6 < Series 2

Should be far more similar to each other than these 2 series:

 1, 2, 3, 4, 5 < Series 1
 1, 1, 5, 8, 7 < Series 2

Any suggestions?

Is there a source code available for it?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

长亭外,古道边 2024-12-26 04:28:57

另一种方法是计算互信息,matlab 和 C 中有一个用于此目的的工具箱
http://www.cs.man.ac.uk/~pococka4/MIToolbox .html

Another way to do this is to calculate mutual information, there is a toolbox for this in matlab and C
http://www.cs.man.ac.uk/~pococka4/MIToolbox.html

远山浅 2024-12-26 04:28:56

您可以计算样本皮尔逊积矩相关系数:“以上公式表明用于计算样本相关性的方便的单通道算法”。编写一个循环来计算 sum(xi)、sum(yi)、sum(xi^2)、sum(yi^2) 和 sum(xi*yi)。然后将这些总和代入公式中。

You can 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.

氛圍 2024-12-26 04:28:56

如果您对相似性的定义是有多少相同的元素,则可以使用集合交集:

std::multiset<int> Series1 = std::multiset({ 1, 2, 3, 4, 5 });
std::multiset<int> Series2 = std::multiset({ 2, 3, 4, 5, 6 });
std::multiset<int> Intersection;

std::set_intersection(Series1.begin(), Series1.end(),
                      Series2.begin(), Series2.end(),
                      std::back_inserter(Intersection));

int similarity = Intersection.size(); // = 4

If your definition of similarity is how much same elements there are you can use set intersection:

std::multiset<int> Series1 = std::multiset({ 1, 2, 3, 4, 5 });
std::multiset<int> Series2 = std::multiset({ 2, 3, 4, 5, 6 });
std::multiset<int> Intersection;

std::set_intersection(Series1.begin(), Series1.end(),
                      Series2.begin(), Series2.end(),
                      std::back_inserter(Intersection));

int similarity = Intersection.size(); // = 4
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文