var

Syntax

var(X)

Arguments

X is a scalar/vector/matrix.

Details

If X is a vector, return the the (unbiased) sample standard variance of X.

If X is a matrix, calculate the the (unbiased) sample standard variance of each column of X and return a vector.

As with all aggregate functions, NULL values are not included in the calculation.

Please note that the result is sample variance instead of population variance.

Examples

$ var(1 1 1);
0
$ var(1 2 3);
1

$ m=matrix(1 3 5 7 9, 1 4 7 10 13);
$ m;

#0

#1

1

1

3

4

5

7

7

10

9

13

$ var(m);
[10,22.5]

Related functions: covar and corr