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

> Realiza regressão linear simples (unidimensional).

# simpleLinearRegression

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

Introduzido em: v20.1.0

Realiza regressão linear simples (unidimensional).

**Sintaxe**

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

**Argumentos**

* `x` — Coluna com os valores da variável explicativa. [`Float64`](/pt-BR/reference/data-types/float)
* `y` — Coluna com os valores da variável dependente. [`Float64`](/pt-BR/reference/data-types/float)

**Valor retornado**

Retorna as constantes `(k, b)` da reta resultante `y = k*x + b`. [`Tuple(Float64, Float64)`](/pt-BR/reference/data-types/tuple)

**Exemplos**

**Ajuste linear perfeito**

```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)                                                             │
└───────────────────────────────────────────────────────────────────┘
```

**Ajuste linear com offset**

```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)                                                             │
└───────────────────────────────────────────────────────────────────┘
```
