<< Support Support distfun_erfcinv >>

Distfun >> Distfun > Support > distfun_cov

distfun_cov

Returns the empirical covariance matrix.

Calling Sequence

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)

Parameters

x:

a matrix of doubles

y:

a matrix of doubles

C:

a square matrix of doubles, the empirical covariance

Description

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.

Examples

x = [1;2];
y = [3;4];
C=distfun_cov(x,y)
expected = [0.5,0.5;0.5,0.5]
//
x = [230;181;165;150;97;192;181;189;172;170];
y = [125;99;97;115;120;100;80;90;95;125];
expected = [
1152.4556,-88.911111
-88.911111,244.26667
]
C=distfun_cov(x,y)

Authors

Bibliography

"Introduction to probability and statistics for engineers and scientists.", Sheldon Ross


Report an issue
<< Support Support distfun_erfcinv >>