Encountered invalid value when I use pearsonr

后端 未结 1 825
醉酒成梦
醉酒成梦 2020-12-16 18:07

Maybe I made a mistake. If so, I am sorry to ask this.

I want to calculate Pearson\'s correlation coefficent by using scipy\'s pearsonr function.

相关标签:
1条回答
  • 2020-12-16 19:10

    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.

    0 讨论(0)
提交回复
热议问题