mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-06 15:42:39 +00:00
1.9 KiB
1.9 KiB
rankCorr
计算等级相关系数。
语法
rankCorr(x, y)
参数
返回值
- Returns a rank correlation coefficient of the ranks of x and y. The value of the correlation coefficient ranges from -1 to +1. If less than two arguments are passed, the function will return an exception. The value close to +1 denotes a high linear relationship, and with an increase of one random variable, the second random variable also increases. The value close to -1 denotes a high linear relationship, and with an increase of one random variable, the second random variable decreases. The value close or equal to 0 denotes no relationship between the two random variables.
类型: Float64。
示例
查询:
SELECT rankCorr(number, number) FROM numbers(100);
结果:
┌─rankCorr(number, number)─┐
│ 1 │
└──────────────────────────┘
查询:
SELECT roundBankers(rankCorr(exp(number), sin(number)), 3) FROM numbers(100);
结果:
┌─roundBankers(rankCorr(exp(number), sin(number)), 3)─┐
│ -0.037 │
└─────────────────────────────────────────────────────┘
参见
- 斯皮尔曼等级相关系数Spearman's rank correlation coefficient