cov, scov

Covariance

cov

Syntax: x cov y, cov[x;y]

Where x and y are conforming numeric lists returns their covariance as a floating-point number. Applies to all numeric data types and signals an error with temporal types, char and sym.

q)2 3 5 7 cov 3 3 5 9
4.5
q)2 3 5 7 cov 4 3 0 2
-1.8125
q)select price cov size by sym from trade

cov is an aggregate function.

scov

Sample covariance

Syntax: x scov y, scov[x;y]

Where x and y are conforming numeric lists returns their sample covariance as a float atom.

scov(x,y)=\frac{n}{n-1}cov(x,y)

Applies to all numeric data types and signals an error with temporal types, char and sym.

q)2 3 5 7 scov 3 3 5 9
8
q)2 3 5 7 scov 4 3 0 2
-2.416667
q)select price scov size by sym from trade

scov is an aggregate function.

var, svar
Wikipedia: Covariance
Basics: Mathematics