window.avg
Compatível com:
window.avg(numeric_values [, should_ignore_zero_values])
Descrição
Retorna a média dos valores de entrada (que podem ser números inteiros ou de ponto flutuante). Definir o segundo argumento opcional como "true" ignora os valores zero.
Tipos de dados de parâmetros
INT|FLOAT
Tipo de retorno
FLOAT
Amostras de código
Exemplo 1
Este exemplo mostra a média de números inteiros.
// 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
Exemplo 2
Este exemplo mostra a média de ponto flutuante.
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
Exemplo 3
Média de entrada negativa
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
Exemplo 4
0 retorna 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
Example 5
Ignorando 0 valores
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