var_pop
Calculates the population variance.
Variance describes the spread of the observations around their arithmetic mean. Its units are the square of the input units.
Syntax
text
var_pop(x)Arguments
x— A numeric column or expression.NULLvalues are skipped.
Calculation
text
sum((x - mean) * (x - mean)) / (n)mean is the arithmetic mean of the non-NULL values, and n is their count. The population calculation uses n because the observations describe the entire population.
Returned value
An approximate REAL value. Empty or all-NULL input returns NULL; one non-NULL input returns 0.0. Nonfinite inputs return NULL; finite arithmetic overflow raises NUMERIC_OVERFLOW.
Examples
Measuring the spread of readings
sql
CREATE TABLE readings (value INTEGER);
INSERT INTO readings VALUES (1), (3), (5), (7), (9), (NULL);sql
SELECT round(var_pop(value), 6) AS result
FROM readings
FORMAT csv;text
8.0A single observation
sql
CREATE TABLE single_reading (value INTEGER);
INSERT INTO single_reading VALUES (7), (NULL);sql
SELECT var_pop(value)
FROM single_reading
FORMAT csv;text
0.0