Quantcast

Documentation Center

  • Trial Software
  • Product Updates

Syntax

V = var(X)
V = var(X,1)
V = var(X,w)
V = var(X,w,dim)

Description

V = 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. For N-dimensional arrays, var operates along the first nonsingleton dimension of X. The result V is an unbiased estimator of the variance of the population from which X is drawn, as long as X consists of independent, identically distributed samples.

var normalizes V by N – 1 if N > 1, where N is the sample size. This is an unbiased estimator of the variance of the population from which X is drawn, as long as X consists of independent, identically distributed samples. For N = 1, V is normalized by 1.

V = var(X,1) normalizes by N and produces the second moment of the sample about its mean. var(X,0) is equivalent to var(X).

V = var(X,w) computes the variance using the weight vector w. The length of w must equal the length of the dimension over which var operates, and its elements must be nonnegative. If X(i) is assumed to have variance proportional to 1/w(i), then V * mean(w)/w(i) is an estimate of the variance of X(i). In other words, V * mean(w) is an estimate of variance for an observation given weight 1.

V = var(X,w,dim) takes the variance along the dimension dim of X. Pass in 0 for w to use the default normalization by N – 1, or 1 to use N.

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

Examples

Create a matrix and find the variance along the dimensions.

X = [4 -2 1; 9 5 7]
var(X,0,1)
ans =
   12.5000   24.5000   18.0000

var(X,0,2)
ans =
     9
     4

See Also

| | | |

Was this topic helpful?