window.avg

Compatible avec :
window.avg(numeric_values [, should_ignore_zero_values])

Description

Renvoie la moyenne des valeurs d'entrée (qui peuvent être des nombres entiers ou à virgule flottante). Si vous définissez le deuxième argument facultatif sur "true", les valeurs nulles sont ignorées.

Types de données des paramètres

INT|FLOAT

Type renvoyé

FLOAT

Exemples de code

Exemple 1

Cet exemple montre la moyenne des nombres entiers.

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

Cet exemple montre la moyenne flottante.

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

Moyenne des entrées négatives

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
Exemple 4

0 retourne 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
Exemple 5

Ignorer les valeurs nulles

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