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

> 数値データの数列から近似分位点を計算します。

# quantileDeterministic

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

導入バージョン: v1.1.0

数値データの数列の近似[分位点](https://en.wikipedia.org/wiki/Quantile)を計算します。

この関数は、最大 8192 のリザーバーサイズを持つ[リザーバーサンプリング](https://en.wikipedia.org/wiki/Reservoir_sampling)と、決定論的なサンプリングアルゴリズムを適用します。
結果は決定論的です。
正確な分位点を求めるには、[`quantileExact`](/ja/reference/functions/aggregate-functions/quantileExact#quantileExact) 関数を使用します。

1 つのクエリで異なるレベルの複数の `quantile*` 関数を使用する場合、内部状態は結合されません (つまり、クエリの実行効率は本来より低くなります) 。
この場合は、[`quantiles`](/ja/reference/functions/aggregate-functions/quantiles#quantiles) 関数を使用します。

**構文**

```sql theme={null}
quantileDeterministic(level)(expr, determinator)
```

**別名**: `medianDeterministic`

**パラメータ**

* `level` — 任意。分位点のレベルです。0 から 1 までの定数浮動小数点数を指定します。`level` の値には `[0.01, 0.99]` の範囲を使用することを推奨します。デフォルト値: 0.5。`level=0.5` の場合、この関数は中央値を計算します。[`Float*`](/ja/reference/data-types/float)

**引数**

* `expr` — カラム値に対する式です。結果のデータ型は、数値型、Date、または DateTime である必要があります。[`(U)Int*`](/ja/reference/data-types/int-uint) または [`Float*`](/ja/reference/data-types/float) または [`Decimal*`](/ja/reference/data-types/decimal) または [`Date`](/ja/reference/data-types/date) または [`DateTime`](/ja/reference/data-types/datetime)
* `determinator` — リザーバサンプリングアルゴリズムで、ランダム数生成器の代わりにそのハッシュが使用され、サンプリング結果を決定論的にするための数値です。`determinator` には、ユーザー ID やイベント ID など、任意の決定論的な正の数を使用できます。同じ `determinator` の値があまりに頻繁に現れると、この関数は正しく動作しません。[`(U)Int*`](/ja/reference/data-types/int-uint)

**戻り値**

指定したレベルの近似分位点を返します。[`Float64`](/ja/reference/data-types/float) または [`Date`](/ja/reference/data-types/date) または [`DateTime`](/ja/reference/data-types/datetime)

**例**

**決定論的な分位点の計算**

```sql title=Query theme={null}
CREATE TABLE t (val UInt32) ENGINE = Memory;
INSERT INTO t VALUES (1), (1), (2), (3);

SELECT quantileDeterministic(val, 1) FROM t;
```

```response title=Response theme={null}
┌─quantileDeterministic(val, 1)─┐
│                           1.5 │
└───────────────────────────────┘
```

**関連項目**

* [median](/ja/reference/functions/aggregate-functions/median)
* [quantiles](/ja/reference/functions/aggregate-functions/quantiles)
