gpt4 book ai didi

python - 计算 PIL 逊相关系数

转载 作者:太空狗 更新时间:2023-10-29 17:56:18 26 4
gpt4 key购买 nike

我正在尝试计算两个变量的 Pearson 相关系数。这些变量用于确定邮政编码的数量与距离范围之间是否存在关系。所以我想看看邮政编码的数量是否随着距离范围的变化而增加/减少。

我将使用一个列表来计算距离范围内邮政编码的数量,而另一个列表将包含实际范围。

有一个包含一系列距离的列表可以吗?或者有一个像 [50, 100, 500, 1000] 这样的列表会更好,其中每个元素将包含该数量的范围。因此,例如列表表示最多 50 公里,然后从 50 公里到 100 公里等等。

最佳答案

使用 scipy :

scipy.stats.pearsonr(x, y)

Calculates a Pearson correlation coefficient and the p-value for testing non-correlation.

The Pearson correlation coefficient measures the linear relationship between two datasets. Strictly speaking, Pearson’s correlation requires that each dataset be normally distributed. Like other correlation coefficients, this one varies between -1 and +1 with 0 implying no correlation. Correlations of -1 or +1 imply an exact linear relationship. Positive correlations imply that as x increases, so does y. Negative correlations imply that as x increases, y decreases.

The p-value roughly indicates the probability of an uncorrelated system producing datasets that have a Pearson correlation at least as extreme as the one computed from these datasets. The p-values are not entirely reliable but are probably reasonable for datasets larger than 500 or so.

Parameters :

x : 1D array

y : 1D array the same length as x

返回:

(Pearson’s correlation coefficient, : 2-tailed p-value)

关于python - 计算 PIL 逊相关系数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13648318/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com