MATLAB Function Reference |

**Syntax**

**Description**

```
var(X)
```

returns the variance of `X`

for vectors. For matrices, `var(X)`

is a row vector containing the variance of each column of `X`

. `var(X)`

normalizes by N-1 where N is the sequence length. This makes `var(X)`

the best unbiased estimate of the variance if `X`

is a sample from a normal distribution.

```
var(X,1)
```

normalizes by N and produces the second moment of the sample about its mean.

```
var(X,W)
```

computes the variance using the weight vector `W`

. The number of elements in `W`

must equal the number of rows in `X`

unless `W = 1`

, which is treated as a short-cut for a vector of ones. The elements of `W`

must be positive. `var`

normalizes `W`

by dividing each element in `W`

by the sum of all its elements.

The variance is the square of the standard deviation (STD).

**See Also**

vander | varargin, varargout |