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

> 모집단 공분산 값을 계산합니다

# covarPopStable

<h2 id="covarPopStable">
  covarPopStable
</h2>

도입 버전: v1.1.0

모집단 공분산(population covariance)을 계산합니다:

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

<br />

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

**구문**

```sql theme={null}
covarPopStable(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)

**반환 값**

`x`와 `y` 사이의 모집단 공분산(population covariance)을 반환합니다. [`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 covarPopStable(x_value, y_value)
FROM series
```

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