ClickHouse/docs/en/sql-reference/aggregate-functions/reference/simplelinearregression.md
Ivan Blinkov 7170f3c534
[docs] split aggregate function and system table references (#11742)
* prefer relative links from root

* wip

* split aggregate function reference

* split system tables
2020-06-18 11:24:31 +03:00

43 lines
1.3 KiB
Markdown

---
toc_priority: 220
---
# simpleLinearRegression {#simplelinearregression}
Performs simple (unidimensional) linear regression.
``` sql
simpleLinearRegression(x, y)
```
Parameters:
- `x` — Column with dependent variable values.
- `y` — Column with explanatory variable values.
Returned values:
Constants `(a, b)` of the resulting line `y = a*x + b`.
**Examples**
``` sql
SELECT arrayReduce('simpleLinearRegression', [0, 1, 2, 3], [0, 1, 2, 3])
```
``` text
┌─arrayReduce('simpleLinearRegression', [0, 1, 2, 3], [0, 1, 2, 3])─┐
│ (1,0) │
└───────────────────────────────────────────────────────────────────┘
```
``` sql
SELECT arrayReduce('simpleLinearRegression', [0, 1, 2, 3], [3, 4, 5, 6])
```
``` text
┌─arrayReduce('simpleLinearRegression', [0, 1, 2, 3], [3, 4, 5, 6])─┐
│ (1,3) │
└───────────────────────────────────────────────────────────────────┘
```