Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DOCSUP-2955: documented the rankCorr function #16109

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
53 changes: 53 additions & 0 deletions docs/en/sql-reference/aggregate-functions/reference/rankCorr.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
## rankCorr {#agg_function-rankcorr}

Computes a rank correlation coefficient.

**Syntax**

``` sql
rankCorr(x, y)
```

**Parameters**

- `x` — Arbitrary value. [Float32](../../../sql-reference/data-types/float.md#float32-float64) or [Float64](../../../sql-reference/data-types/float.md#float32-float64).
- `y` — Arbitrary value. [Float32](../../../sql-reference/data-types/float.md#float32-float64) or [Float64](../../../sql-reference/data-types/float.md#float32-float64).

**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](../../../sql-reference/data-types/float.md#float32-float64).

**Example**

Query:

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

Result:

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

Query:

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

Result:

``` text
┌─roundBankers(rankCorr(exp(number), sin(number)), 3)─┐
│ -0.037 │
└─────────────────────────────────────────────────────┘
```
**See Also**

- [Spearman's rank correlation coefficient](https://en.wikipedia.org/wiki/Spearman%27s_rank_correlation_coefficient)
53 changes: 53 additions & 0 deletions docs/ru/sql-reference/aggregate-functions/reference/rankCorr.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
## rankCorr {#agg_function-rankcorr}

Вычисляет коэффициент ранговой корреляции.

**Синтаксис**

``` sql
rankCorr(x, y)
```

**Параметры**

- `x` — Произвольное значение. [Float32](../../../sql-reference/data-types/float.md#float32-float64) или [Float64](../../../sql-reference/data-types/float.md#float32-float64).
- `y` — Произвольное значение. [Float32](../../../sql-reference/data-types/float.md#float32-float64) или [Float64](../../../sql-reference/data-types/float.md#float32-float64).

**Возвращаемое значение**

- Возвращает коэффициент ранговой корреляции рангов x и y. Значение коэффициента корреляции изменяется в пределах от -1 до +1. Если передается менее двух аргументов, функция возвращает исключение. Значение, близкое к +1, указывает на высокую линейную зависимость, и с увеличением одной случайной величины увеличивается и вторая случайная величина. Значение, близкое к -1, указывает на высокую линейную зависимость, и с увеличением одной случайной величины вторая случайная величина уменьшается. Значение, близкое или равное 0, означает отсутствие связи между двумя случайными величинами.

Тип: [Float64](../../../sql-reference/data-types/float.md#float32-float64).

**Пример**

Запрос:

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

Результат:

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

Запрос:

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

Результат:

``` text
┌─roundBankers(rankCorr(exp(number), sin(number)), 3)─┐
│ -0.037 │
└─────────────────────────────────────────────────────┘
```
**Смотрите также**

- [Коэффициент ранговой корреляции Спирмена](https://ru.wikipedia.org/wiki/%D0%9A%D0%BE%D1%80%D1%80%D0%B5%D0%BB%D1%8F%D1%86%D0%B8%D1%8F#%D0%9A%D0%BE%D1%8D%D1%84%D1%84%D0%B8%D1%86%D0%B8%D0%B5%D0%BD%D1%82_%D1%80%D0%B0%D0%BD%D0%B3%D0%BE%D0%B2%D0%BE%D0%B9_%D0%BA%D0%BE%D1%80%D1%80%D0%B5%D0%BB%D1%8F%D1%86%D0%B8%D0%B8_%D0%A1%D0%BF%D0%B8%D1%80%D0%BC%D0%B5%D0%BD%D0%B0)