stdev

Return the standard deviation of the value of the specified field.

put|reduce stdev(field)
Parameter Description Required?
field The field to compute Yes

Example

This example uses the batch processor.

// On historical data, you can apply reducer to get a single computation,
// or batch your historical data by time, then reduce per batch period.

sub historical_points() { 
  emit -from :0: -limit 10 
  | put value = Math.floor(Math.random() * 100)
}
historical_points 
| reduce avg(value), stdev = stdev(value)
| view table -title "Historical average and standard deviation"
;
historical_points 
| batch 5 
| reduce avg(value), stdev = stdev(value) 
| view table
    -update "append" 
    -title "Historical 5-second average and standard deviation"
;

// On live streaming data, you must batch by time, then reduce per batch period.

sub live_points() {
  emit -limit 10 
  | put cnt = count(), value = Math.floor(Math.random() * 100)
}
live_points 
| batch 3 
| reduce avg(value), stdev = stdev(value)
| view table 
    -update "append" 
    -title "Live 3-second average and standard deviation"
;