Variance

`V = var(`

returns
the variance of the
elements of `A`

)`A`

along the first array dimension whose
size does not equal 1.

If

`A`

is a vector of observations, the variance is a scalar.If

`A`

is a matrix whose columns are random variables and whose rows are observations,`V`

is a row vector containing the variances corresponding to each column.If

`A`

is a multidimensional array, then`var(A)`

treats the values along the first array dimension whose size does not equal 1 as vectors. The size of this dimension becomes`1`

while the sizes of all other dimensions remain the same.The variance is normalized by the number of observations

`-1`

by default.If

`A`

is a scalar,`var(A)`

returns`0`

. If`A`

is a`0`

-by-`0`

empty array,`var(A)`

returns`NaN`

.

`V = var(`

specifies
a weighting scheme. When `A`

,`w`

)`w = 0`

(default), `V`

is
normalized by the number of observations`-1`

. When ```
w
= 1
```

, it is normalized by the number of observations. `w`

can
also be a weight vector containing nonnegative elements. In this case,
the length of `w`

must equal the length of the dimension
over which `var`

is operating.

`V = var(`

computes the variance over the dimensions specified in the vector
`A`

,`w`

,`vecdim`

)`vecdim`

when `w`

is 0 or 1. For example, if
`A`

is a matrix, then `var(A,0,[1 2])`

computes the variance over all elements in `A`

, since every element
of a matrix is contained in the array slice defined by dimensions 1 and 2.