|MATLAB Function Reference|
X is a vector, returns the variance. For matrices, where each row is an observation, and each column is a variable,
cov(X) is the covariance matrix.
diag(cov(X)) is a vector of variances for each column, and
sqrt(diag(cov(X))) is a vector of standard deviations.
Y are vectors of equal length, is equivalent to
cov(X,Y) normalizes by N-1 where N is the number of observations. This makes
cov(X) the best unbiased estimate of the covariance matrix if the observations are from a normal distribution.
cov(X,Y,1) normalizes by N and produces the second moment matrix of the observations about their mean.
cov(X,Y,0) is the same as
cov(X,0) is the same as
cov removes the mean from each column before calculating the result.
The covariance function is defined as
where is the mathematical expectation and .
A = [-1 1 2 ; -2 3 1 ; 4 0 3]. To obtain a vector of variances for each column of
v with covariance matrix
The diagonal elements
C(i,i) represent the variances for the columns of
A. The off-diagonal elements
C(i,j) represent the covariances of columns
xcov in the Signal Processing Toolbox
© 1994-2005 The MathWorks, Inc.