| Statistics Toolbox | Search  Help Desk |
| var | Examples See Also |
Syntax
y = var(X) y = var(X,1) y = var(X,w)
Description
var(X) computes the variance of the data in X. For vectors, var(x) is the variance of the elements in x. 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. For normally distributed data, this makes var(x) the minimum variance unbiased estimator MVUE of
2(the second parameter) .
var(x,1) normalizes by n and yields the second moment of the sample data about its mean (moment of inertia).
var(X,w) computes the variance using the vector of weights, w. The number of elements in w must equal the number of rows in the matrix, X. For vector x, w and x must match in length. Each element of w must be positive.
var supports both common definitions of variance. Let SS be the sum of x, from their mean. Then, var(x) = SS/(n-1) the MVUE, and var(x,1) = SS/n the maximum likelihood estimator (MLE) of
2.
Examples
x = [-1 1];
w = [1 3];
v1 = var(x)
v1 =
2
v2 = var(x,1)
v2 =
1
v3 = var(x,w)
v3 =
0.7500
See Also
cov,std