Covariance

Covariance[v1,v2]
gives the covariance between the vectors v1 and v2.

Covariance[m]
gives the covariance matrix for the matrix m.

Covariance[m1,m2]
gives the covariance matrix for the matrices m1 and m2.

Covariance[dist]
gives the covariance matrix for the multivariate symbolic distribution dist.

Covariance[dist,i,j]
gives the (i,j)^(th) covariance for the multivariate symbolic distribution dist.

DetailsDetails

  • Covariance[v1,v2] gives the unbiased estimate of the covariance between v1 and v2.
  • The lists v1 and v2 must be the same length.
  • Covariance[v1,v2] is equivalent to (v1-Mean[v1]). Conjugate[v2-Mean[v2]]/(Length[v1]-1).
  • For a matrix m with columns, Covariance[m] is a × matrix of the covariances between columns of m.
  • For an × matrix m1 and an × matrix m2, Covariance[m1,m2] is a × matrix of the covariances between columns of m1 and columns of m2.
  • Covariance works with SparseArray objects.
  • Covariance[dist,i,j] gives Expectation[(xi-μi)(xj-μj),{x1,x2,}dist], where μi is the i^(th) component of the mean of dist.
  • Covariance[dist] gives a covariance matrix with the (i,j)^(th) entry given by Covariance[dist,i,j].

ExamplesExamplesopen allclose all

Basic Examples  (3)Basic Examples  (3)

Covariance between two vectors:

In[1]:=
Click for copyable input
Out[1]=

Covariance matrix for a matrix:

In[1]:=
Click for copyable input
Out[1]//MatrixForm=

Covariance matrix for two matrices:

In[1]:=
Click for copyable input
Out[1]//MatrixForm=
Introduced in 2007
(6.0)
| Updated in 2010
(8.0)