次の方法で共有


percentile()、percentiles() (集計関数)

Applies to: ✅Microsoft FabricAzure Data ExplorerAzure MonitorMicrosoft Sentinel

The percentile() function calculates an estimate for the specified nearest-rank percentile of the population defined by expr. 精度は、パーセンタイル リージョンの人口密度によって異なります。

percentiles() は、 percentile()と同様に機能します。 ただし、 percentiles() では複数のパーセンタイル値を一度に計算できます。これは、各パーセンタイル値を個別に計算するよりも効率的です。

To calculate weighted percentiles, see percentilesw().

Note

This function is used in conjunction with the summarize operator.

Syntax

percentile( expr,percentile)

percentiles( expr,percentiles)

Learn more about syntax conventions.

Parameters

Name タイプ Required Description
expr string ✔️ 集計計算に使用する式。
percentile real ✔️ パーセンタイルを指定する定数。
percentiles real ✔️ 1 つ以上のコンマ区切り百分位数。

Returns

Returns a table with the estimates for expr of the specified percentiles in the group, each in a separate column.

Note

1 つの列のパーセンタイルを返すには、「 百分位数を配列として返す」を参照してください

Examples

このセクションの例では、構文を使用して作業を開始する方法を示します。

The examples in this article use publicly available tables in the help cluster, such as the StormEvents table in the Samples database.

The examples in this article use publicly available tables, such as the Weather table in the Weather analytics sample gallery. ワークスペース内のテーブルと一致するように、クエリ例のテーブル名を変更する必要がある場合があります。

単一パーセンタイルの計算

次の例は、 DamageProperty の値がサンプル セットの 95% を超え、サンプル セットの 5% 未満であることを示しています。

StormEvents | summarize percentile(DamageProperty, 95) by State

Output

表示される結果テーブルには、最初の 10 行のみが含まれます。

State percentile_DamageProperty_95
ATLANTIC SOUTH 0
FLORIDA 40000
GEORGIA 143333
MISSISSIPPI 80000
AMERICAN SAMOA 250000
KENTUCKY 35000
OHIO 150000
KANSAS 51392
MICHIGAN 49167
ALABAMA 50000

複数のパーセンタイルを計算する

次の例は、5、50 (中央値) と 95 を使用して同時に計算される DamageProperty の値を示しています。

StormEvents | summarize percentiles(DamageProperty, 5, 50, 95) by State

Output

表示される結果テーブルには、最初の 10 行のみが含まれます。

State percentile_DamageProperty_5 percentile_DamageProperty_50 percentile_DamageProperty_95
ATLANTIC SOUTH 0 0 0
FLORIDA 0 0 40000
GEORGIA 0 0 143333
MISSISSIPPI 0 0 80000
AMERICAN SAMOA 0 0 250000
KENTUCKY 0 0 35000
OHIO 0 2000 150000
KANSAS 0 0 51392
MICHIGAN 0 0 49167
ALABAMA 0 0 50000
... ...

パーセンタイルを配列として返す

個々の列の値を返す代わりに、 percentiles_array() 関数を使用して、動的配列型の単一列のパーセンタイルを返します。

Syntax

percentiles_array( expr,percentiles)

Parameters

Name タイプ Required Description
expr string ✔️ 集計計算に使用する式。
percentiles 実数または動的 ✔️ 1 つ以上のコンマ区切り百分位数またはパーセンタイルの動的配列。 各パーセンタイルは実際の値である必要があります。

Returns

Returns an estimate for expr of the specified percentiles in the group as a single column of dynamic array type.

Examples

Comma-separated percentiles

Multiple percentiles can be obtained as an array in a single dynamic column, instead of in multiple columns as with percentiles().

TransformedSensorsData
| summarize percentiles_array(Value, 5, 25, 50, 75, 95), avg(Value) by SensorName

Output

結果テーブルには、最初の 10 行のみが表示されます。

SensorName percentiles_Value avg_Value
sensor-82 ["0.048141473520867069","0.24407515500271132","0.48974511106780577","0.74160998970950343","0.94587903204190071"] 0.493950914
sensor-130 ["0.049200214398937764","0.25735850440187535","0.51206374010048239","0.74182335059053839","0.95210342463616771"] 0.505111463
sensor-56 ["0.04857779335488676","0.24709868149337144","0.49668762923789589","0.74458470404241883","0.94889104840865857"] 0.497955018
sensor-24 ["0.051507199150534679","0.24803904945640423","0.50397070213183581","0.75653888126010793","0.9518782718727431"] 0.501084379
sensor-47 ["0.045991246974755672","0.24644331118208851","0.48089197707088743","0.74475142784472248","0.9518322864959039"] 0.49386228
sensor-135 ["0.05132897529660399","0.24204987641954018","0.48470113942206461","0.74275730068433621","0.94784079559229406"] 0.494817619
sensor-74 ["0.048914714739047828","0.25160926036445724","0.49832498850160978","0.75257887767110776","0.94932261924236094"] 0.501627252
sensor-173 ["0.048333149363009836","0.26084250046756496","0.51288012531934613","0.74964772791583412","0.95156058795294"] 0.505401226
sensor-28 ["0.048511161184567046","0.2547387968731824","0.50101318228599656","0.75693845702682039","0.95243122486483989"] 0.502066244
sensor-34 ["0.049980293859462954","0.25094722564949412","0.50914023067384762","0.75571549713447961","0.95176564809278674"] 0.504309494
... ... ...

パーセンタイルの動的配列

percentiles_arrayのパーセンタイルは、整数または浮動小数点数の動的配列で指定できます。 配列は、定数にする必要がありますが、リテラルにする必要はありません。

TransformedSensorsData
| summarize percentiles_array(Value, dynamic([5, 25, 50, 75, 95])), avg(Value) by SensorName

Output

結果テーブルには、最初の 10 行のみが表示されます。

SensorName percentiles_Value avg_Value
sensor-82 ["0.048141473520867069","0.24407515500271132","0.48974511106780577","0.74160998970950343","0.94587903204190071"] 0.493950914
sensor-130 ["0.049200214398937764","0.25735850440187535","0.51206374010048239","0.74182335059053839","0.95210342463616771"] 0.505111463
sensor-56 ["0.04857779335488676","0.24709868149337144","0.49668762923789589","0.74458470404241883","0.94889104840865857"] 0.497955018
sensor-24 ["0.051507199150534679","0.24803904945640423","0.50397070213183581","0.75653888126010793","0.9518782718727431"] 0.501084379
sensor-47 ["0.045991246974755672","0.24644331118208851","0.48089197707088743","0.74475142784472248","0.9518322864959039"] 0.49386228
sensor-135 ["0.05132897529660399","0.24204987641954018","0.48470113942206461","0.74275730068433621","0.94784079559229406"] 0.494817619
sensor-74 ["0.048914714739047828","0.25160926036445724","0.49832498850160978","0.75257887767110776","0.94932261924236094"] 0.501627252
sensor-173 ["0.048333149363009836","0.26084250046756496","0.51288012531934613","0.74964772791583412","0.95156058795294"] 0.505401226
sensor-28 ["0.048511161184567046","0.2547387968731824","0.50101318228599656","0.75693845702682039","0.95243122486483989"] 0.502066244
sensor-34 ["0.049980293859462954","0.25094722564949412","0.50914023067384762","0.75571549713447961","0.95176564809278674"] 0.504309494
... ... ...

Nearest-rank percentile

P-th percentile (0 <P<= 100) of a list of ordered values, sorted in ascending order, is the smallest value in the list. The P percent of the data is less or equal to P-th percentile value (from Wikipedia article on percentiles).

Define 0-th percentiles to be the smallest member of the population.

Note

計算の近似特性を考えると、実際に返される値は、母集団のメンバーではない可能性があります。 Nearest-rank definition means that P=50 does not conform to the interpolative definition of the median. When evaluating the significance of this discrepancy for the specific application, the size of the population and an estimation error should be taken into account.

パーセンタイル単位の推定エラー

The percentiles aggregate provides an approximate value using T-Digest.

Note

  • 推定エラーの限度は、要求されたパーセンタイルの値によって異なります。 最適な精度は、[0..100] のスケールの両端です。 パーセンタイルの 0 と 100 が分布の正確な最小値と最大値です。 精度はスケールの中央に向かって徐々に低下します。 中央値で最低で、1% で最大です。
  • エラー限度は、値ではなく、ランクで観測されます。 percentile(X, 50) が Xm の値を返したとします。 推定では、X の値の 49% 以上 51% 以下が Xm 以下になることが保証されます。 Xm と X の実際の中央値との差には、理論上の制限はありません。
  • 推定によって正確な値が返される場合もありますが、それがいつなのかを定義するための信頼できる条件はありません。