ClickHouse/docs/en/sql-reference/aggregate-functions/reference/rankCorr.md
Anna Shakhova 0ae690e6ed
DOCSUP-2955: documented the rankCorr function (#16109)
* rankCorr: init commit in English.

* Fixed

* Fixed links.

* Fixed link.

* Fixed link.

* Fixed link.

* Fixed link to document Float32

* Fixed remarks

* Fixed

* Translation
2020-11-27 19:56:38 +03:00

1.9 KiB

rankCorr

Computes a rank correlation coefficient.

Syntax

rankCorr(x, y)

Parameters

Returned value(s)

  • 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.

Type: Float64.

Example

Query:

SELECT rankCorr(number, number) FROM numbers(100);

Result:

┌─rankCorr(number, number)─┐
│                        1 │
└──────────────────────────┘

Query:

SELECT roundBankers(rankCorr(exp(number), sin(number)), 3) FROM numbers(100);

Result:

┌─roundBankers(rankCorr(exp(number), sin(number)), 3)─┐
│                                              -0.037 │
└─────────────────────────────────────────────────────┘

See Also