window.avg
Compatível com:
window.avg(numeric_values [, should_ignore_zero_values])
Descrição
Devolve a média dos valores de entrada (que podem ser números inteiros ou números de vírgula flutuante). Definir o segundo argumento opcional como verdadeiro ignora os valores zero.
Tipos de dados de parâmetros
INT|FLOAT
Tipo devolvido
FLOAT
Exemplos 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 flutuação.
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 entradas negativas
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 devoluções 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
Exemplo 5
A ignorar valores 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