window.avg

Didukung di:
window.avg(numeric_values [, should_ignore_zero_values])

Deskripsi

Menampilkan rata-rata nilai input (yang dapat berupa Integer atau Float). Menetapkan argumen kedua opsional ke benar (true) akan mengabaikan nilai nol.

Jenis data parameter

INT|FLOAT

Jenis hasil yang ditampilkan

FLOAT

Contoh kode

Contoh 1

Contoh ini menunjukkan rata-rata bilangan bulat.

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

Contoh ini menunjukkan rata-rata float.

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

Rata-rata input negatif

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

0 pengembalian 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
Contoh 5

Mengabaikan 0 nilai

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