stddev()
Calculates the population standard deviation of numeric values returned by an expression.
Syntax
Parameters
NUM_EXPR- An expression that returns the numeric values for which to calculate the standard deviation.
Description
The stddev() function internally computes the square root of var(NUM_EXPR). Because it is based on the population variance (divided by N), it returns the population standard deviation. Null values and non-numeric values are ignored. If there are no values, it returns null. If there is exactly one value, it returns 0.0. The return value is a 64-bit floating-point number (double).
Use this function in aggregation commands such as stats and timechart.
Error codes
| Code | Description |
|---|---|
| 91020 | The number of arguments is incorrect. |
Usage examples
To prepare the WEB_APACHE_SAMPLE table used in these examples, refer to Preparing sample data.
-
Calculate the standard deviation of response sizes across all requests
table WEB_APACHE_SAMPLE | stats stddev(bytes) -
Calculate the standard deviation of response sizes per HTTP method
table WEB_APACHE_SAMPLE | stats stddev(bytes) by method -
Null value handling
json "[{'val': 10}, {'val': null}, {'val': 30}]" | stats stddev(val) | # Null values are ignored.
Compatibility
The stddev() function has been available since before Logpresso Sonar 4.0.