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

> 피어슨 상관계수를 계산합니다.

# corr

<h2 id="corr">
  corr
</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 />

<Note>
  이 함수는 수치적으로 불안정한 알고리즘을 사용합니다. 계산에서 [수치 안정성](https://en.wikipedia.org/wiki/Numerical_stability)이 필요한 경우 [`corrStable`](/reference/functions/aggregate-functions/corrStable) 함수를 사용하십시오. 속도는 느리지만 더 정확한 결과를 제공합니다.
</Note>

**구문**

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

**인수**

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

**반환 값**

피어슨 상관계수를 반환합니다. [`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 corr(x_value, y_value)
FROM series
```

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