皮尔逊系数与斯皮尔曼系数(The Pearson Correlation and The Spearman Correlation )

  1. The Pearson Correlation: from -1 to 1 measuring the linear relationship between two variables

  2. The Spearman Correlation: from -1 to 1 measuring the monotonic relationship between two variables

The Spearman correlation is 1 if as one variable increases, the other does as well, even if the relationship is not linear. On the other hand, the Pearson correlation can only be one if the increase is exactly linear. These are best illustrated by example.


python中两种相关系数的代码

from scipy.stats import spearmanr
import numpy as np
spr = spearmanr(x, y).correlation
pcr = np.corrcoef(x, y)[0, 1]

皮尔逊系数与斯皮尔曼系数(The Pearson Correlation and The Spearman Correlation )

皮尔逊系数与斯皮尔曼系数(The Pearson Correlation and The Spearman Correlation )

版权声明

本文仅代表作者观点,不代表本站立场。
本文系作者授权发表,未经许可,不得转载。

评论