Encountered invalid value when I use pearsonr

早过忘川 提交于 2019-11-29 03:56:14

Pearson's correlation coefficient between two variables is defined as the covariance of the two variables divided by the product of their standard deviations.

So it's the covariance over

  • the standard deviation of [4, 5, 5, 4, 4, 4] times
  • the standard deviation of [4, 4, 4, 4, 4, 4].

The standard deviation of [4, 4, 4, 4, 4, 4] is zero.

So it's the covariance over

  • the standard deviation of [4, 5, 5, 4, 4, 4] times
  • zero.

So it's the covariance over

  • zero.

Anything divided by zero is nan. The value of the covariance is irrelevant.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!