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

> 数値データの数列に対する分位点を正確に計算します。

# quantileExactInclusive

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

導入バージョン: v20.1.0

[`quantileExact`](/ja/reference/functions/aggregate-functions/quantileExact) と同様に、この関数は数値データの数列の正確な [分位点](https://en.wikipedia.org/wiki/Quantile) を計算します。

この関数は [`quantileExact`](/ja/reference/functions/aggregate-functions/quantileExact) と同等ですが、[R-7法](https://en.wikipedia.org/wiki/Quantile#Estimating_quantiles_from_a_sample) で説明されている包含方式で分位点を計算します。

この関数を使用すると、指定した分位点 p に対する補間式が `x[floor((n-1)*p)] + ((n-1)*p - floor((n-1)*p)) * (x[floor((n-1)*p)+1] - x[floor((n-1)*p)])` の形になるように分位点が計算されます。ここで、x はソート済みの配列です。

正確な値を得るために、渡されたすべての値はいったん 1 つの配列にまとめられ、その後完全にソートされます。
ソートアルゴリズムの計算量は `O(N·log(N))` で、ここで `N = std::distance(first, last)` は比較回数です。

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

**構文**

```sql theme={null}
quantileExactInclusive(level)(expr)
```

**パラメータ**

* `level` — 分位点のレベル。0 から 1 まで (両端を含む) の定数の浮動小数点数です。`level` の値には `[0.01, 0.99]` の範囲を使用することを推奨します。[`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)

**戻り値**

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

**例**

**厳密な inclusive 分位点の計算**

```sql title=Query theme={null}
SELECT quantileExactInclusive(0.25)(number) FROM numbers(5);
```

```response title=Response theme={null}
┌─quantileExactInclusive(0.25)(number)─┐
│                                    1 │
└──────────────────────────────────────┘
```

**複数の分位点レベルの計算**

```sql title=Query theme={null}
SELECT quantileExactInclusive(0.1)(number), quantileExactInclusive(0.9)(number) FROM numbers(10);
```

```response title=Response theme={null}
┌─quantileExactInclusive(0.1)(number)─┬─quantileExactInclusive(0.9)(number)─┐
│                                 0.9 │                                 8.1 │
└─────────────────────────────────────┴─────────────────────────────────────┘
```
