Does doubling all readings change Pearson correlation?
corrcoef normalizes covariance by the variables' standard deviations to measure linear association.
numpy.corrcoef in practice
When one column is exactly twice another varying column, their correlation is one. A constant column has zero standard deviation and makes the ratio undefined.
import numpy as np
np.corrcoef([2,4,6],[4,8,12]).round(6)Result [[1.0, 1.0], [1.0, 1.0]]
中文
把读数统一翻倍会改变皮尔逊相关吗?
corrcoef 将协方差按两个变量的标准差归一化,衡量线性关系方向与强度。
numpy.corrcoef 算例
一列是另一列的两倍,两列相关系数为 1。若其中一列为常量,标准差为零,此时该比值没有定义。
import numpy as np
np.corrcoef([2,4,6],[4,8,12]).round(6)结果 [[1.0, 1.0], [1.0, 1.0]]