COV covariance matrix X and Y can contain missing values encoded with NaN. NaN's are skipped, NaN do not result in a NaN output. The output gives NaN only if there are insufficient input data The mean is removed from the data. Remark: for data contains missing values, the resulting matrix might not be positiv definite, and its elements have magnitudes larger than one. This ill-behavior is more likely for small sample sizes, but there is no garantee that the result "behaves well" for larger sample sizes. If you want the a "well behaved" result (i.e. positive definiteness and magnitude of elements not larger than 1), use CORRCOEF. However, COV is faster than CORRCOEF and might be good enough in some cases. C = COV(X [,Mode]); calculates the (auto-)correlation matrix of X C = COV(X,Y [,Mode]); calculates the crosscorrelation between X and Y. C(i,j) is the correlation between the i-th and jth column of X and Y, respectively. NOTE: Octave and Matlab have (in some special cases) incompatible implemenations. This implementation follows Octave. If the result could be ambigous or incompatible, a warning will be presented in Matlab. To avoid this warning use: a) use COV([X(:),Y(:)]) if you want the traditional Matlab result. b) use C = COV([X,Y]), C = C(1:size(X,2),size(X,2)+1:size(C,2)); if you want to be compatible with this software. Mode = 0 [default] scales C by (N-1) Mode = 1 scales C by N. see also: COVM, COR, CORRCOEF, SUMSKIPNAN REFERENCES: http://mathworld.wolfram.com/Covariance.html
Package: nan