window.avg
以下でサポートされています。
window.avg(numeric_values [, should_ignore_zero_values])
説明
入力値(整数または浮動小数点数)の平均値を返します。省略可能な 2 番目の引数を true に設定すると、ゼロ値が無視されます。
パラメータのデータ型
INT|FLOAT
戻り値の型
FLOAT
コードサンプル
例 1
この例では、整数の平均を示します。
// 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
例 2
この例では、浮動小数点数の平均を示します。
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
例 3
ネガティブな入力の平均
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
例 4
0 は 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
例 5
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