window.avg
window.avg(numeric_values [, should_ignore_zero_values])
Beschreibung
Gibt den Durchschnitt der Eingabewerte zurück (die Ganzzahlen oder Gleitkommazahlen sein können). Wenn Sie das optionale zweite Argument auf „true“ setzen, werden Nullwerte ignoriert.
Parameterdatentypen
INT|FLOAT
Rückgabetyp
FLOAT
Codebeispiele
Beispiel 1
In diesem Beispiel wird der durchschnittliche Ganzzahlwert angezeigt.
// 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
Beispiel 2
In diesem Beispiel wird der Gleitkommadurchschnitt gezeigt.
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
Beispiel 3
Durchschnittlicher negativer Input
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
Beispiel 4
0 gibt 0 zurück
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
Beispiel 5
0-Werte ignorieren
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