Skip to content

cov

Covariance.

V = cov(X)
V = cov(X, Y)
V = cov(X, Y, flag)

With one matrix argument X, returns the N×N covariance matrix of the columns of X (N = size(X, 2)). With two vector arguments, returns the scalar covariance between X and Y. The flag (0 for N-1 normalization, 1 for N) controls whether the unbiased or biased estimator is used.

cov([1 2 3 4; 4 3 2 1]')
% [1.6667 -1.6667; -1.6667 1.6667]
  • std — Standard deviation.
  • var — Variance.
  • mean — Arithmetic mean.