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

> 回帰直線の傾きを返します。

# regr_slope

<h2 id="regr_slope">
  regr\_slope
</h2>

導入バージョン: v26.9.0

`x` に対する `y` の最小二乗回帰直線の傾きを返します:

$$
\frac{\Sigma{(x - \bar{x})(y - \bar{y})}}{\Sigma{(x - \bar{x})^2}}
$$

`x` が定数の場合は回帰直線が垂直になるため、`nan` を返します。

**構文**

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

**別名**: `regrSlope`

**引数**

* `y` — 目的変数。 [`(U)Int*`](/reference/data-types/int-uint) または [`Float*`](/reference/data-types/float)
* `x` — 説明変数。 [`(U)Int*`](/reference/data-types/int-uint) または [`Float*`](/reference/data-types/float)

**戻り値**

回帰直線の傾きを返します。 [`Float64`](/reference/data-types/float)

**例**

**基本的な使い方**

```sql title=Query theme={null}
SELECT regr_slope(y, x)
FROM VALUES('x Float64, y Float64', (1, 2), (2, 4), (3, 6), (4, 8))
```

```response title=Response theme={null}
┌─regr_slope(y, x)─┐
│                2 │
└──────────────────┘
```
