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

> Вычисляет простую (одномерную) линейную регрессию.

# simpleLinearRegression

<div id="simpleLinearRegression">
  ## simpleLinearRegression
</div>

Добавленный в: v20.1.0

Выполняет простую (одномерную) линейную регрессию.

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

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

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

* `x` — Столбец со значениями независимой переменной. [`Float64`](/ru/reference/data-types/float)
* `y` — Столбец со значениями зависимой переменной. [`Float64`](/ru/reference/data-types/float)

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

Возвращает константы `(k, b)` полученной прямой `y = k*x + b`. [`Tuple(Float64, Float64)`](/ru/reference/data-types/tuple)

**Примеры**

**Идеальная линейная аппроксимация**

```sql title=Query theme={null}
SELECT arrayReduce('simpleLinearRegression', [0, 1, 2, 3], [0, 1, 2, 3]);
```

```response title=Response theme={null}
┌─arrayReduce('simpleLinearRegression', [0, 1, 2, 3], [0, 1, 2, 3])─┐
│ (1,0)                                                             │
└───────────────────────────────────────────────────────────────────┘
```

**Линейная аппроксимация со смещением**

```sql title=Query theme={null}
SELECT arrayReduce('simpleLinearRegression', [0, 1, 2, 3], [3, 4, 5, 6]);
```

```response title=Response theme={null}
┌─arrayReduce('simpleLinearRegression', [0, 1, 2, 3], [3, 4, 5, 6])─┐
│ (1,3)                                                             │
└───────────────────────────────────────────────────────────────────┘
```
