stdev — aggregate function to return the standard deviation of a range of values.
This function computes a value for each record returned by the query predicate, or from the specified column of a base table, and returns the standard deviation of those values.
Standard deviation is a measure of the dispersion of a set of data from its mean. The more spread apart the data is, the higher the deviation. For example, in financial applications, standard deviation could be applied to the annual rate of return of an investment to measure the investment's volatility (risk). A volatile stock would have a high standard deviation. In mutual funds, the standard deviation indicates how much the return on the fund is currently deviating from the expected normal returns.
expr must be the name of a column in a LiveView table, where that column's data type is int, long, double, or timestamp. If the
field's type is an int, double, or long, it returns a double. If the field's type is a timestamp, it returns an interval timestamp.
For timestamp values, the input field should contain all interval timestamps or all absolute timestamps, but not both.
This function calculates its return value based on the unbiased or n-1 method, and is usually used when the incoming data represents a random sample of data. Use stdevp for a similar function that calculates its return value using the biased or n method, which is used when the incoming data represents an entire population of data.
This example shows how to use dynamic aggregation to find the standard deviation of the values in a column. In the Hello LiveView sample, create a query that finds the standard deviation value of the quantityRemaining field from the ItemSales table, grouping by Item. Follow these steps:
In LiveView Desktop connected to a server running the Hello LiveView sample, select the ItemsSales table from the Tables pane of the LiveView Tables view.
In the Select field, enter:
category, stdev(quantityRemaining) AS stdQuantity
In the Query field, enter the following:
group by category
The query results open in a grid view. LiveView Server recalculates the standard deviation value whenever the rows returned by the query predicate change.
This LiveView aggregate function is based on the stdev aggregate function in the StreamBase expression language.