Returns the empirical covariance matrix.
C=distfun_cov(x) C=distfun_cov(x,0) C=distfun_cov(x,1) C=distfun_cov(x,y) C=distfun_cov(x,y,0) C=distfun_cov(x,y,1)
a matrix of doubles
a matrix of doubles
a square matrix of doubles, the empirical covariance
If x is a nobs-by-1 matrix, then distfun_cov(x) returns the variance of x, normalized by nobs-1.
If x is a nobs-by-nvar matrix, then distfun_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 distfun_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.
distfun_cov(x,0) is the same as distfun_cov(x) and distfun_cov(x,y,0) is the same as distfun_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.
distfun_cov(x,1) and distfun_cov(x,y,1) normalize by nobs. In this case, C is the second moment matrix of the observations about their mean.
"Introduction to probability and statistics for engineers and scientists.", Sheldon Ross