且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Scipy:距离相关性高于1

更新时间:2023-01-02 21:25:19

根据文档,我看不出这是为什么。

I don't see why this is a problem according to the documentation.

来自文档


u和v之间的相关距离定义为 1-racfrac {(u-\bar {u})\cdot(v-\bar {v})}
{{||(u-\bar {u})|| } _2 {||(v-\bar {v})||} _2}

通过 Cauchy-Schwarz不等式,减号后的表达式带有绝对值为1 。但是,并没有规定它不会是负数的-实际上,如果(平均归一化的)向量是反相关的,就会发生这种情况。

By the Cauchy-Schwarz Inequality, the expression following the minus sign has an absolute value that is at most 1. There is nothing stipulating that it won't be negative, though - in fact, this will happen if the (mean normalized) vectors are anticorrelated.

AFAICT,您应该如果您得到的值大于2或小于0感到很惊讶。使用@Cleb的注释以及范围为[0,2]的事实,我猜想其他一些包将距离简单地定义为一半这个表达式。

AFAICT, you should be surprised if you'd get a value larger than 2 or smaller than 0. Using the comment by @Cleb and the fact that the range is [0, 2], I'm guessing that some other packages simply define the distance as half this expression.