window.variance

נתמך ב:
window.variance(values)

תיאור

הפונקציה מחזירה את השונות שצוינה של ערכי הקלט.

סוגי נתונים של פרמטרים

INT|FLOAT

סוג הערך שמוחזר

FLOAT

דוגמאות קוד

דוגמה 1

בדוגמה הזו מוחזרת השונות של כל המספרים השלמים.

// This rule creates a detection when the file size variance in 5 minutes for a user is over a threshold.
events:
 $e.user.userid = $userid
match:
 $userid over 5m
outcome:
  $p1 = window.variance($e.file.size) // yields 16 if the event file size values in the match window are [10, 14, 18].
condition:
  $e and #p1 > 10
דוגמה 2

בדוגמה הזו מוחזרת השונות של כל המספרים העשרוניים.

events:
 $e.user.userid = $userid
match:
 $userid over 5m
outcome:
  $p1 = window.variance($e.file.size) // yields 20.148300 if the event file size values in the match window are [10.00, 14.80, 18.97].
condition:
  $e and #p1 > 10
דוגמה 3

בדוגמה הזו מוחזרת השונות של מספרים שליליים.

events:
 $e.user.userid = $userid
match:
 $userid over 5m
outcome:
  $p1 = window.variance($e.file.size) // yields 2366.333333 if the event file size values in the match window are [-1, -56, -98].
condition:
  $e and #p1 > 10
דוגמה 4

בדוגמה הזו מוחזר ערך קטן של שונות.

events:
 $e.user.userid = $userid
match:
 $userid over 5m
outcome:
  $p1 = window.variance($e.file.size) // yields 0.000000 if the event file size values in the match window are [0.000000, 0.000000, 0.000100].
condition:
  $e and #p1 > 10
דוגמה 5

בדוגמה הזו, השונות היא אפס.

events:
 $e.user.userid = $userid
match:
 $userid over 5m
outcome:
  $p1 = window.variance($e.file.size) // yields 0.000000 if the event file size values in the match window are [1, 1, 1].
condition:
  $e and #p1 > 10
דוגמה 6

בדוגמה הזו מוחזרת השונות של מספרים חיוביים ושליליים.

events:
 $e.user.userid = $userid
match:
 $userid over 5m
outcome:
  $p1 = window.variance($e.file.size) // yields 1.000000 if the event file size values in the match window are [1, 0, -1].
condition:
  $e and #p1 > 10