> ## Documentation Index
> Fetch the complete documentation index at: https://private-7c7dfe99-detect-table-modification.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

> Возвращает угловой коэффициент линии регрессии.

# regr_slope

<h2 id="regr_slope">
  regr\_slope
</h2>

Добавлено в: v26.9.0

Возвращает угловой коэффициент линии регрессии `y` по `x`, построенной методом наименьших квадратов:

$$
\frac{\Sigma{(x - \bar{x})(y - \bar{y})}}{\Sigma{(x - \bar{x})^2}}
$$

Возвращает `nan`, если `x` — константа, так как в этом случае линия регрессии вертикальна.

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

```sql theme={null}
regr_slope(y, x)
```

**Псевдонимы**: `regrSlope`

**Аргументы**

* `y` — Зависимая переменная. [`(U)Int*`](/reference/data-types/int-uint) или [`Float*`](/reference/data-types/float)
* `x` — Независимая переменная. [`(U)Int*`](/reference/data-types/int-uint) или [`Float*`](/reference/data-types/float)

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

Возвращает угловой коэффициент линии регрессии. [`Float64`](/reference/data-types/float)

**Примеры**

**Базовое использование**

```sql title=Query theme={null}
SELECT regr_slope(y, x)
FROM VALUES('x Float64, y Float64', (1, 2), (2, 4), (3, 6), (4, 8))
```

```response title=Response theme={null}
┌─regr_slope(y, x)─┐
│                2 │
└──────────────────┘
```
