Compute the covariance matrix.
If each row of x and y is an observation, and each column is
a variable, then the (i, j)-th entry of
cov (x, y)
is the covariance between the i-th
variable in x and the j-th variable in y.
cov (x) = 1/N-1 * SUM_i (x(i) - mean(x)) * (y(i) - mean(y))
If called with one argument, compute cov (x, x)
, the
covariance between the columns of x.
The argument opt determines the type of normalization to use. Valid values are
normalize with N-1, provides the best unbiased estimator of the covariance [default]
normalize with N, this provides the second moment around the mean
Compatibility Note:: Octave always computes the covariance matrix.
For two inputs, however, MATLAB will calculate
cov (x(:), y(:))
whenever the number of elements in
x and y are equal. This will result in a scalar rather than
a matrix output. Code relying on this odd definition will need to be
changed when running in Octave.
See also: corr.
Package: octave