函数 corr #
计算包含数值的两个列表的相关系数。对于矩阵,则计算矩阵相关系数。
Syntax #
math.corr(A, B)
Parameters #
| Parameter | Type | Description |
|---|---|---|
A |
Array | Matrix | 用于计算相关系数的第一个数组或矩阵 |
B |
Array | Matrix | 用于计算相关系数的第二个数组或矩阵 |
Returns #
| Type | Description |
|---|---|
| * | 相关系数 |
Throws #
Type | Description —- | ———–
Examples #
math.corr([1, 2, 3, 4, 5], [4, 5, 6, 7, 8]) // returns 1
math.corr([1, 2.2, 3, 4.8, 5], [4, 5.3, 6.6, 7, 8]) //returns 0.9569941688503644
math.corr([[1, 2.2, 3, 4.8, 5], [4, 5.3, 6.6, 7, 8]],[[1, 2.2, 3, 4.8, 5], [4, 5.3, 6.6, 7, 8]]) // returns [1,1]