window.avg

Disponible en:
window.avg(numeric_values [, should_ignore_zero_values])

Descripción

Devuelve la media de los valores de entrada (que pueden ser números enteros o de coma flotante). Si asignas el valor "true" al segundo argumento opcional, se ignorarán los valores cero.

Tipos de datos de parámetros

INT|FLOAT

Tipo de devolución

FLOAT

Códigos de ejemplo

Ejemplo 1

En este ejemplo se muestra la media de números enteros.

// 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
Ejemplo 2

En este ejemplo se muestra la media de los valores flotantes.

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
Ejemplo 3

Media de las 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
Ejemplo 4

0 devoluciones 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
Ejemplo 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