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

> 피어슨 상관계수를 계산하며, 수치적으로 안정적인 알고리즘을 사용합니다.

# corrStable

<h2 id="corrStable">
  corrStable
</h2>

도입 버전: v1.1.0

[피어슨 상관계수](https://en.wikipedia.org/wiki/Pearson_correlation_coefficient)를 계산합니다:

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

<br />

[`corr`](/reference/functions/aggregate-functions/corr) 함수와 유사하지만, 수치적으로 안정적인 알고리즘을 사용합니다.
따라서 `corrStable`은 `corr`보다 느리지만 더 정확한 결과를 반환합니다.

**구문**

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

**인수**

* `x` — 첫 번째 변수. [`(U)Int*`](/reference/data-types/int-uint) 또는 [`Float*`](/reference/data-types/float) 또는 [`Decimal`](/reference/data-types/decimal)
* `y` — 두 번째 변수. [`(U)Int*`](/reference/data-types/int-uint) 또는 [`Float*`](/reference/data-types/float) 또는 [`Decimal`](/reference/data-types/decimal)

**반환 값**

피어슨 상관계수를 반환합니다. [`Float64`](/reference/data-types/float)

**예시**

**안정적인 알고리즘을 사용한 기본 상관관계 계산**

```sql title=Query theme={null}
DROP TABLE IF EXISTS series;
CREATE TABLE series
(
    i UInt32,
    x_value Float64,
    y_value Float64
)
ENGINE = Memory;
INSERT INTO series(i, x_value, y_value) VALUES (1, 5.6, -4.4),(2, -9.6, 3),(3, -1.3, -4),(4, 5.3, 9.7),(5, 4.4, 0.037),(6, -8.6, -7.8),(7, 5.1, 9.3),(8, 7.9, -3.6),(9, -8.2, 0.62),(10, -3, 7.3);

SELECT corrStable(x_value, y_value)
FROM series
```

```response title=Response theme={null}
┌─corrStable(x_value, y_value)─┐
│          0.17302657554532558 │
└──────────────────────────────┘
```
