Versions:
variance(), variance_y(), and variance_x() ToolkitTimescaleDB Toolkit functions are available under Timescale Community Edition. They are automatically included with Timescale Cloud. Click to learn more.
Toolkit
TimescaleDB Toolkit functions are available under Timescale Community Edition. They are automatically included with Timescale Cloud. Click to learn more.
variance(summary StatsSummary1D, method TEXT) RETURNS BIGINT
variance_y(summary StatsSummary2D, method TEXT) RETURNS BIGINT
variance_x(summary StatsSummary2D, method TEXT) RETURNS BIGINT
Get the variance of the values contained in a statistical aggregate.
In a two-dimensional stats_agg
use the _y
/ _x
form to access the
variance
of the dependent and independent variables.
The method
determines whether you calculate a population or sample variance.
These values can be provided as their full names, or you can abbreviate them to pop
or samp
. These are the only four accepted values for the method
argument. The
default is sample
.
For more information about statistical aggregate functions, see the hyperfunctions documentation.
Required arguments
Name | Type | Description |
---|---|---|
summary | StatsSummary1D /StatsSummary2D | The already constructed data structure from a previous stats_agg call |
Optional arguments
Name | Type | Description |
---|---|---|
method | TEXT | The method for the calculation 'population' or 'sample' (default) |
Returns
Column | Type | Description |
---|---|---|
variance /variance_y /variance_x | DOUBLE PRECISION | The variance of the values in the statistical aggregate |
Sample usage
SELECT variance_y(stats_agg(data, data))
FROM generate_series(0, 100) data;
variance_y
------------
858.5
Found an issue on this page?
Report an issue!