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

<h2 id="regr_intercept">
  regr\_intercept
</h2>

引入版本：v26.9.0

返回 `y` 关于 `x` 的最小二乘拟合直线的截距：

$$
\bar{y} - slope \cdot \bar{x}
$$

当 `x` 为常量时返回 `nan`，因为此时拟合直线为垂直线。

**语法**

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

**别名**：`regrIntercept`

**参数**

* `y` — 因变量。[`(U)Int*`](/zh/reference/data-types/int-uint) 或 [`Float*`](/zh/reference/data-types/float)
* `x` — 自变量。[`(U)Int*`](/zh/reference/data-types/int-uint) 或 [`Float*`](/zh/reference/data-types/float)

**返回值**

返回回归直线的截距。[`Float64`](/zh/reference/data-types/float)

**示例**

**基本用法**

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

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