未验证 提交 77ce50aa 编写于 作者: A alexey-milovidov 提交者: GitHub

Merge pull request #5403 from BayoNet/DOCAPI-6423-leastSqr

DOCAPI-6423: leastSqr description.
......@@ -580,5 +580,41 @@ Calculates the value of `Σ((x - x̅)(y - y̅)) / n`.
Calculates the Pearson correlation coefficient: `Σ((x - x̅)(y - y̅)) / sqrt(Σ((x - x̅)^2) * Σ((y - y̅)^2))`.
## simpleLinearRegression
Performs simple (unidimensional) linear regression.
```
simpleLinearRegression(x, y)
```
Parameters:
- `x` — Column with values of dependent variable.
- `y` — Column with explanatory variable.
Returned values:
Parameters `(a, b)` of the resulting line `x = a*y + 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) │
└───────────────────────────────────────────────────────────────────┘
```
[Original article](https://clickhouse.yandex/docs/en/query_language/agg_functions/reference/) <!--hide-->
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册