Covariance matrix
C=cov(x) C=cov(x,0) C=cov(x,1) C=cov(x,y) C=cov(x,y,0) C=cov(x,y,1)
a nobs-by-1 or nobs-by-nvar matrix of doubles
a nobs-by-1 or nobs-by-nvar matrix of doubles
a square matrix of doubles, the empirical covariance
If x is a nobs-by-1 matrix,
then cov(x)
returns the variance of x,
normalized by nobs-1.
If x is a nobs-by-nvar matrix,
then cov(x)
returns the nvar-by-nvar covariance matrix of the
columns of x, normalized by nobs-1.
Here, each column of x is a variable and
each row of x is an observation.
If x and y are two nobs-by-1 matrices,
then cov(x,y)
returns the 2-by-2 covariance matrix of x and
y, normalized by nobs-1, where nobs is the number of observations.
cov(x,0)
is the same as cov(x)
and
cov(x,y,0)
is the same as cov(x,y)
.
In this case, if the population is from a normal distribution,
then C is the best unbiased estimate of the covariance matrix.
cov(x,1)
and cov(x,y,1)
normalize by nobs.
In this case, C is the second moment matrix of the
observations about their mean.
The covariance of X and Y is defined by
where E is the expectation.
This function is compatible with Matlab.
[1] http://en.wikipedia.org/wiki/Covariance_matrix
[2] "Introduction to probability and statistics for engineers and scientists.", Sheldon Ross
[3] NIST/SEMATECH e-Handbook of Statistical Methods, 6.5.4.1. Mean Vector and Covariance Matrix, http://www.itl.nist.gov/div898/handbook/pmc/section5/pmc541.htm