跳转到主内容
跳转到主内容

varPop

varPop

Introduced in: v1.1

Calculates the population variance.

The population variance is calculated using the formula:

Σ(xxˉ)2n\frac{\Sigma{(x - \bar{x})^2}}{n}

Where:

  • xx is each value in the population
  • xˉ\bar{x} is the population mean
  • nn is the population size
注意

此函数使用数值不稳定的算法。如果您在计算中需要数值稳定性,请使用 varPopStable 函数。该函数运行速度较慢,但计算误差更小。

Syntax

varPop(x)

Aliases: VAR_POP

Arguments

Returned value

Returns the population variance of x. Float64

Examples

Computing population variance

DROP TABLE IF EXISTS test_data;
CREATE TABLE test_data
(
    x UInt8,
)
ENGINE = Memory;

INSERT INTO test_data VALUES (3), (3), (3), (4), (4), (5), (5), (7), (11), (15);

SELECT
    varPop(x) AS var_pop
FROM test_data;
┌─var_pop─┐
│    14.4 │
└─────────┘