window.avg
Supportato in:
window.avg(numeric_values [, should_ignore_zero_values])
Descrizione
Restituisce la media dei valori di input (che possono essere numeri interi o numeri in virgola mobile). Se imposti il secondo argomento facoltativo su true, i valori zero vengono ignorati.
Tipi di dati dei parametri
INT|FLOAT
Tipo restituito
FLOAT
Esempi di codice
Esempio 1
Questo esempio mostra la media intera.
// This rule sets the outcome $size_mode to the average
// file size in the 5 minute match window.
events:
$e.user.userid = $userid
match:
$userid over 5m
outcome:
$size_mode = window.avg($e.file.size) // yields 2.5 if the event file size values in the match window are 1, 2, 3 and 4
Esempio 2
Questo esempio mostra la media mobile.
events:
$e.user.userid = $userid
match:
$userid over 5m
outcome:
$size_mode = window.avg($e.file.size) // yields 1.75 if the event file size values in the match window are 1.1 and 2.4
Esempio 3
Media input negativi
events:
$e.user.userid = $userid
match:
$userid over 5m
outcome:
$size_mode = window.avg($e.file.size) // yields 0.6 if the event file size values in the match window are -1.1, 1.1, 0.0 and 2.4
Esempio 4
0 resi 0
events:
$e.user.userid = $userid
match:
$userid over 5m
outcome:
$size_mode = window.avg($e.file.size) // yields 0 if the event file size values in the match window is 0
Esempio 5
Ignorare i valori pari a 0
events:
$e.user.userid = $userid
match:
$userid over 5m
outcome:
$size_mode = window.avg($e.file.size, true) // yields 394 if the event file size values in the match window are 0, 0, 0 and 394