Numpy 的 corrcoef(~)
方法计算给定两个数组的 Pearson 相关系数:
参数
1. x
| array-like
每行代表一个单独的列数据(即变量)。请参阅下面的示例以进行说明。
2. y
| array-like
| optional
您无需将数据集指定为 x 中的新行,只需将其指定为 y
即可。
3. rowvar
| boolean
| optional
如果为 True,则 x 中的每一行代表一个变量。如果为 False,则 x 中的每一列代表一个变量。默认情况下,rowvar=True
。
返回值
包含给定数据集的相关系数的 Numpy 数组。
例子
基本用法
np.corrcoef([2,3,5,6],[3,5,8,12])
array([[1. , 0.97913005],
[0.97913005, 1. ]])
这与指定二维数组完全相同:
np.corrcoef([[2,3,5,6],[3,5,8,12]])
array([[1. , 0.97913005],
[0.97913005, 1. ]])
相关用法
- Python codecs.decode()用法及代码示例
- Python collections.somenamedtuple._replace用法及代码示例
- Python collections.somenamedtuple._asdict用法及代码示例
- Python compile()用法及代码示例
- Python NumPy compress方法用法及代码示例
- Python collections.somenamedtuple._field_defaults用法及代码示例
- Python NumPy cov方法用法及代码示例
- Python codecs.encode()用法及代码示例
- Python contextlib.AsyncContextDecorator用法及代码示例
- Python collections.ChainMap用法及代码示例
- Python contextlib.AsyncExitStack用法及代码示例
- Python string count()用法及代码示例
- Python collections.somenamedtuple._make用法及代码示例
- Python NumPy count_nonzero方法用法及代码示例
- Python configparser.ConfigParser.readfp用法及代码示例
- Python code.compile_command()用法及代码示例
- Python Wand color_matrix()用法及代码示例
- Python configparser.ConfigParser.BOOLEAN_STATES用法及代码示例
- Python math copysign()用法及代码示例
- Python PIL composite()用法及代码示例
- Python codeop.compile_command用法及代码示例
- Python contextlib.ExitStack.pop_all用法及代码示例
- Python contextlib.redirect_stdout用法及代码示例
- Python collections.Counter用法及代码示例
- Python configparser.BasicInterpolation用法及代码示例
注:本文由纯净天空筛选整理自Isshin Inada大神的英文原创作品 NumPy | corrcoef method。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。