> ## Documentation Index
> Fetch the complete documentation index at: https://private-7c7dfe99-fix-nav-issues.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`](/ja/reference/data-types/float)
* `y` — 従属変数の値が入ったカラム。[`Float64`](/ja/reference/data-types/float)

**戻り値**

求められる直線 `y = k*x + b` の定数 `(k, b)` を返します。[`Tuple(Float64, Float64)`](/ja/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)                                                             │
└───────────────────────────────────────────────────────────────────┘
```
