Udostępnij przez


percentyl(), percentyls() (funkcja agregacji)

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. Dokładność zależy od gęstości populacji w regionie percentyla.

percentiles() działa podobnie do percentile(). percentiles() Można jednak obliczyć jednocześnie wiele wartości percentylu, co jest bardziej wydajne niż oddzielne obliczanie każdej wartości percentylu.

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 Typ Required Description
expr string ✔️ Wyrażenie używane do obliczania agregacji.
percentile real ✔️ Stała określająca percentyl.
percentiles real ✔️ Co najmniej jeden percentyl rozdzielony przecinkami.

Returns

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

Note

Aby zwrócić percentyle w jednej kolumnie, zobacz Zwracanie percentyli jako tablicy.

Examples

W przykładach w tej sekcji pokazano, jak używać składni, aby ułatwić rozpoczęcie pracy.

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. Może być konieczne zmodyfikowanie nazwy tabeli w przykładowym zapytaniu, aby było zgodne z tabelą w obszarze roboczym.

Obliczanie pojedynczego percentylu

W poniższym przykładzie pokazano, że wartość DamageProperty jest większa niż 95% zestawu próbek i mniejsza niż 5% zestawu próbek.

StormEvents | summarize percentile(DamageProperty, 95) by State

Output

Wyświetlona tabela wyników zawiera tylko pierwsze 10 wierszy.

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

Obliczanie wielu percentylów

W poniższym przykładzie przedstawiono wartość równocześnie obliczoną DamageProperty przy użyciu wartości 5, 50 (mediana) i 95.

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

Output

Wyświetlona tabela wyników zawiera tylko pierwsze 10 wierszy.

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

Zwracanie percentyli jako tablicy

Zamiast zwracać wartości w poszczególnych kolumnach, użyj percentiles_array() funkcji , aby zwrócić percentyle w jednej kolumnie typu tablicy dynamicznej.

Syntax

percentiles_array( expr,percentiles)

Parameters

Name Typ Required Description
expr string ✔️ Wyrażenie używane do obliczania agregacji.
percentiles rzeczywiste lub dynamiczne ✔️ Co najmniej jeden percentyl rozdzielony przecinkami lub tablica dynamiczna percentylu. Każdy percentyl musi być rzeczywistą wartością.

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

W tabeli wyników są wyświetlane tylko pierwsze 10 wierszy.

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

Tablica dynamiczna percentylów

Percentyle dla percentiles_array elementu można określić w dynamicznej tablicy liczb całkowitych lub zmiennoprzecinkowych. Tablica musi być stała, ale nie musi być literałem.

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

Output

W tabeli wyników są wyświetlane tylko pierwsze 10 wierszy.

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

Biorąc pod uwagę zbliżający się charakter obliczenia, rzeczywista zwrócona wartość może nie być członkiem populacji. 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.

Błąd szacowania w percentylach

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

Note

  • Granice błędu szacowania różnią się w zależności od wartości żądanego percentylu. Najlepszą dokładnością jest na obu końcach skali [0..100]. Percentyle 0 i 100 to dokładne wartości minimalne i maksymalne rozkładu. Dokładność stopniowo zmniejsza się w kierunku środka skali. Jest to najgorsze w medianie i jest ograniczona do 1%.
  • Ograniczenia błędów są obserwowane w klasyfikacji, a nie na wartości. Załóżmy, że percentyl(X, 50) zwrócił wartość Xm. Oszacowanie gwarantuje, że co najmniej 49% i co najwyżej 51% wartości X są mniejsze lub równe Xm. Nie ma teoretycznego limitu różnicy między Xm a rzeczywistą medianą wartości X.
  • Szacowanie może czasami spowodować dokładną wartość, ale nie ma wiarygodnych warunków do zdefiniowania, kiedy tak będzie.