用法:
statistics.correlation(x, y, /)
返回兩個輸入的Pearson’s correlation coefficient。 Pearson 的相關係數
r
取值介於 -1 和 +1 之間。它衡量線性關係的強度和方向,其中+1表示非常強,正線性關係,-1表示非常強,負線性關係,0表示沒有線性關係。兩個輸入必須具有相同的長度(不少於兩個),並且不必是恒定的,否則會引發
StatisticsError
。例子:
>>> x = [1, 2, 3, 4, 5, 6, 7, 8, 9] >>> y = [9, 8, 7, 6, 5, 4, 3, 2, 1] >>> correlation(x, x) 1.0 >>> correlation(x, y) -1.0
3.10 版中的新函數。
相關用法
- Python statistics.covariance用法及代碼示例
- Python statistics.median_grouped用法及代碼示例
- Python statistics.median_high用法及代碼示例
- Python statistics.quantiles用法及代碼示例
- Python statistics.multimode用法及代碼示例
- Python statistics.mean用法及代碼示例
- Python statistics.median用法及代碼示例
- Python statistics.NormalDist用法及代碼示例
- Python statistics.median_low用法及代碼示例
- Python statistics.mode用法及代碼示例
- Python statistics.linear_regression用法及代碼示例
- Python statistics.pvariance用法及代碼示例
- Python statistics.harmonic_mean用法及代碼示例
- Python statistics.variance用法及代碼示例
- Python statistics mean()用法及代碼示例
- Python staticmethod()用法及代碼示例
- Python staticmethod用法及代碼示例
- Python Scipy stats.cumfreq()用法及代碼示例
- Python Scipy stats.nanmean()用法及代碼示例
- Python Scipy stats.gengamma()用法及代碼示例
注:本文由純淨天空篩選整理自python.org大神的英文原創作品 statistics.correlation。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。