Skip to content

var, svar

Variance, Sample variance

var

Variance

Syntax: var x, var[x]

Where x is a numeric list, returns its variance as a float atom. Nulls are ignored.

q)var 2 3 5 7
3.6875
q)var 2 3 5 0n 7
3.6875
q)select var price by sym from trade where date=2010.10.10,sym in`IBM`MSFT

var is an aggregate function.

svar

Sample variance

Syntax: svar x, svar[x]

Where x is a numeric list, returns its sample variance as a float atom.

svar(x)=\frac{n}{n-1}var(x)
q)var 2 3 5 7
3.6875
q)svar 2 3 5 7
4.916667
q)select svar price by sym from trade where date=2010.10.10,sym in`IBM`MSFT

svar is an aggregate function.

cov, scov
Wikipedia: Covariance, Variance
financereference.com: Variance
Basics: Mathematics