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

> quantilesGK는 quantileGK와 비슷하게 작동하지만, 여러 수준의 분위수를 동시에 계산할 수 있고 배열을 반환합니다.

# quantilesGK

<div id="quantilesGK">
  ## quantilesGK
</div>

도입 버전: v23.4.0

[Greenwald-Khanna](http://infolab.stanford.edu/~datar/courses/cs361a/papers/quantiles.pdf) 알고리즘을 사용하여 숫자 데이터 시퀀스의 여러 [분위수](https://en.wikipedia.org/wiki/Quantile)를 서로 다른 수준에서 동시에 계산합니다.

이 함수는 [`quantileGK`](/ko/reference/functions/aggregate-functions/quantileGK)와 비슷하게 동작하지만, 단일 패스로 여러 분위수 수준을 계산할 수 있으므로 개별 분위수 함수를 각각 호출하는 것보다 더 효율적입니다.

Greenwald-Khanna 알고리즘은 데이터 스트림에서 분위수를 매우 효율적으로 계산하는 데 사용되는 알고리즘입니다.
이 알고리즘은 2001년에 Michael Greenwald와 Sanjeev Khanna가 제안했습니다.
이 알고리즘은 매우 효율적이며, 항목당 O(log n) 공간과 O(log log n) 시간만 사용합니다(n은 입력 크기).
또한 정확도도 매우 높아, 제어 가능한 정확도로 근사 분위수 값을 제공합니다.

**구문**

```sql theme={null}
quantilesGK(accuracy, level1, level2, ...)(expr)
```

**매개변수**

* `accuracy` — 분위수의 정확도입니다. 상수 양의 정수입니다. 정확도 값이 클수록 오류는 작아집니다. 예를 들어 `accuracy` 인수가 100으로 설정되면 계산된 분위수는 높은 확률로 1%를 넘지 않는 오류를 가집니다. 계산된 분위수의 정확도와 알고리즘의 계산 복잡도 사이에는 상충 관계가 있습니다. [`UInt*`](/ko/reference/data-types/int-uint)
* `level` — 분위수 수준입니다. 0에서 1 사이의 하나 이상의 상수 부동소수점 수입니다. [`Float*`](/ko/reference/data-types/float)

**인수**

* `expr` — 컬럼 값에 대한 표현식이며, 결과는 숫자 데이터 타입, Date 또는 DateTime이어야 합니다. [`(U)Int*`](/ko/reference/data-types/int-uint) 또는 [`Float*`](/ko/reference/data-types/float) 또는 [`Decimal*`](/ko/reference/data-types/decimal) 또는 [`Date`](/ko/reference/data-types/date) 또는 [`DateTime`](/ko/reference/data-types/datetime)

**반환 값**

지정한 수준의 분위수 배열입니다. 지정한 수준의 순서와 동일한 순서로 반환됩니다. [`Array(Float64)`](/ko/reference/data-types/array) 또는 [`Array(Date)`](/ko/reference/data-types/array) 또는 [`Array(DateTime)`](/ko/reference/data-types/array)

**예시**

**GK 알고리즘으로 여러 분위수 계산**

```sql title=Query theme={null}
SELECT quantilesGK(1, 0.25, 0.5, 0.75)(number + 1) FROM numbers(1000);
```

```response title=Response theme={null}
┌─quantilesGK(1, 0.25, 0.5, 0.75)(plus(number, 1))─┐
│ [1, 1, 1]                                        │
└──────────────────────────────────────────────────┘
```

**더 정확한 분위수**

```sql title=Query theme={null}
SELECT quantilesGK(100, 0.25, 0.5, 0.75)(number + 1) FROM numbers(1000);
```

```response title=Response theme={null}
┌─quantilesGK(100, 0.25, 0.5, 0.75)(plus(number, 1))─┐
│ [251, 498, 741]                                    │
└────────────────────────────────────────────────────┘
```
