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

> 一定の精度で、各シーケンス要素の重みに基づいて数値データ列の分位点を計算します。

# quantilesTimingWeighted

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

導入バージョン: v1.1.0

各シーケンス要素の重みを考慮しながら、一定の精度で、数値データ列の複数の[分位点](https://en.wikipedia.org/wiki/Quantile)を異なるレベルで同時に計算します。

この関数は [`quantileTimingWeighted`](/ja/reference/functions/aggregate-functions/quantileTimingWeighted) と同等ですが、1 回の処理で複数の分位点レベルを計算できるため、個別に分位点関数を呼び出すよりも効率的です。

結果は決定論的です (クエリの処理順序に依存しません) 。この関数は、Web ページの読み込み時間やバックエンドの応答時間のような分布を表すシーケンスを扱うよう最適化されています。

**Accuracy**

計算が正確になるのは、次の場合です。

* 値の総数が 5670 を超えない。
* 値の総数が 5670 を超えていても、ページの読み込み時間が 1024ms 未満である。

それ以外の場合、計算結果は最も近い 16 ms の倍数に丸められます。

<Note>
  ページの読み込み時間の分位点を計算する場合、この関数は [`quantiles`](/ja/reference/functions/aggregate-functions/quantiles) よりも効率的で高精度です。
</Note>

**Syntax**

```sql theme={null}
quantilesTimingWeighted(level1, level2, ...)(expr, weight)
```

**パラメータ**

* `level` — 分位点のレベル。0 から 1 までの 1 つ以上の定数の浮動小数点数です。`level` の値には `[0.01, 0.99]` の範囲を使用することを推奨します。[`Float*`](/ja/reference/data-types/float)

**引数**

* `expr` — カラムの値に対する式で、Float\* 型の数値を返します。負の値が関数に渡された場合の動作は未定義です。値が 30,000 を超える場合 (ページの読み込み時間が 30 秒を超える場合) は、30,000 と見なされます。[`Float*`](/ja/reference/data-types/float)
* `weight` — シーケンス要素の重みを持つカラム。`weight` は値の出現回数です。[`UInt*`](/ja/reference/data-types/int-uint)

**戻り値**

指定したレベルの分位点を、指定したレベルと同じ順序で格納した Array。[`Array(Float32)`](/ja/reference/data-types/array)

**例**

**複数の重み付きタイミング分位点を計算する**

```sql title=Query theme={null}
SELECT quantilesTimingWeighted(0.5, 0.99)(response_time, weight) FROM t;
```

```response title=Response theme={null}
┌─quantilesTimingWeighted(0.5, 0.99)(response_time, weight)─┐
│ [112, 162]                                                │
└───────────────────────────────────────────────────────────┘
```

**関連項目**

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