Covariance
✖
Covariance

gives the auto-covariance matrix for the multivariate symbolic distribution dist.
Details


- Covariance is typically used to measure covariation, i.e. whether one variable tends to vary similarly to another.
- Covariance[v,w] gives the unbiased estimate of the covariance
between v and w.
- For vectors
and
of length
, the covariance estimate Covariance[v,w] is given by
with
=Mean[v].
- For matrices
and
with dimensions
and
and columns indexed as
and
, respectively, Covariance[a,b] is a
matrix with elements given by
:
- where
is an
-vector of ones,
is Mean[a] and
is Mean[b].
- For a matrix a with
columns, Covariance[a] is a
matrix given by Covariance[a, a].
- Covariance works with any vector that is VectorQ or matrix that is MatrixQ.
- Covariance[dist,i,j] gives Expectation[(xi-μi)(xj-μj),{x1,x2,…}∈dist], where μi is the i
component of the mean of dist. »
- Covariance[dist] gives a covariance matrix with the (i,j)
entry given by Covariance[dist,i,j]. »



Examples
open allclose allBasic Examples (3)Summary of the most common use cases
Scope (13)Survey of the scope of standard use cases
Data (8)
Exact input yields exact output:

https://wolfram.com/xid/0b0keq7yl5a-eta06h


https://wolfram.com/xid/0b0keq7yl5a-mszqlu

Approximate input yields approximate output:

https://wolfram.com/xid/0b0keq7yl5a-bxeync


https://wolfram.com/xid/0b0keq7yl5a-04fgr

Covariance between vectors of complexes:

https://wolfram.com/xid/0b0keq7yl5a-dbahpf


https://wolfram.com/xid/0b0keq7yl5a-kt50m4

A structured array can be used (see the guide):

https://wolfram.com/xid/0b0keq7yl5a-h2htud


https://wolfram.com/xid/0b0keq7yl5a-v51wbj


https://wolfram.com/xid/0b0keq7yl5a-eoq11l


https://wolfram.com/xid/0b0keq7yl5a-6l5n0m

Find the covariance for data involving quantities:

https://wolfram.com/xid/0b0keq7yl5a-rui6zn

https://wolfram.com/xid/0b0keq7yl5a-e8c21s

Covariance between lists of dates:

https://wolfram.com/xid/0b0keq7yl5a-vvw1aa


https://wolfram.com/xid/0b0keq7yl5a-4bj6vf


https://wolfram.com/xid/0b0keq7yl5a-p2rqb3

Covariance between matrices of times:

https://wolfram.com/xid/0b0keq7yl5a-vu0sut

Distributions and Processes (5)
Covariance for a continuous multivariate distribution:

https://wolfram.com/xid/0b0keq7yl5a-fnv00k


https://wolfram.com/xid/0b0keq7yl5a-tekwa

Covariance for a discrete multivariate distribution:

https://wolfram.com/xid/0b0keq7yl5a-epq4i


https://wolfram.com/xid/0b0keq7yl5a-fmicv5

Covariance for derived distributions:

https://wolfram.com/xid/0b0keq7yl5a-c3a9y


https://wolfram.com/xid/0b0keq7yl5a-cy97of

https://wolfram.com/xid/0b0keq7yl5a-etkwz


https://wolfram.com/xid/0b0keq7yl5a-tmnd9


https://wolfram.com/xid/0b0keq7yl5a-kla8wx


https://wolfram.com/xid/0b0keq7yl5a-hxjash

https://wolfram.com/xid/0b0keq7yl5a-gm1a47


https://wolfram.com/xid/0b0keq7yl5a-edj4ah

Covariance matrix for a random process at times s and t:

https://wolfram.com/xid/0b0keq7yl5a-hv1ygl

Covariance matrix for TemporalData at times and
:

https://wolfram.com/xid/0b0keq7yl5a-butvlp


https://wolfram.com/xid/0b0keq7yl5a-k1q1tr

Compare to the covariance of the process slice:

https://wolfram.com/xid/0b0keq7yl5a-m9xt34

Applications (3)Sample problems that can be solved with this function
Compute the covariance of two financial time series:

https://wolfram.com/xid/0b0keq7yl5a-zdbiqi

https://wolfram.com/xid/0b0keq7yl5a-3a8yoh

https://wolfram.com/xid/0b0keq7yl5a-2q6d2

Covariance can be used to measure linear association:

https://wolfram.com/xid/0b0keq7yl5a-bcl86

https://wolfram.com/xid/0b0keq7yl5a-g1rlnp

Covariance can only detect monotonic relationships:

https://wolfram.com/xid/0b0keq7yl5a-7nvfr

https://wolfram.com/xid/0b0keq7yl5a-nazb6e

https://wolfram.com/xid/0b0keq7yl5a-j9qi3

https://wolfram.com/xid/0b0keq7yl5a-gtfa0z

HoeffdingD can be used to detect a variety of dependence structures:

https://wolfram.com/xid/0b0keq7yl5a-jor85u

Properties & Relations (9)Properties of the function, and connections to other functions
The covariance matrix is symmetric and positive semidefinite:

https://wolfram.com/xid/0b0keq7yl5a-31bc2

https://wolfram.com/xid/0b0keq7yl5a-mmzf9d


https://wolfram.com/xid/0b0keq7yl5a-c9urx7

A covariance matrix scaled by standard deviations is a correlation matrix:

https://wolfram.com/xid/0b0keq7yl5a-o3dafo

https://wolfram.com/xid/0b0keq7yl5a-d6zye

https://wolfram.com/xid/0b0keq7yl5a-dz7nph

Covariance and AbsoluteCorrelation are the same for a distribution with zero mean:

https://wolfram.com/xid/0b0keq7yl5a-b4nkgn

https://wolfram.com/xid/0b0keq7yl5a-cbk1sj


https://wolfram.com/xid/0b0keq7yl5a-dqzrcn


https://wolfram.com/xid/0b0keq7yl5a-h10yhb

SpearmanRho is related to Covariance applied to ranks:

https://wolfram.com/xid/0b0keq7yl5a-cbzhhv

https://wolfram.com/xid/0b0keq7yl5a-pzf7jv


https://wolfram.com/xid/0b0keq7yl5a-j0lyo

https://wolfram.com/xid/0b0keq7yl5a-bvkzz

CovarianceFunction for a process is the off-diagonal entry in the covariance matrix:

https://wolfram.com/xid/0b0keq7yl5a-c8x3e0

https://wolfram.com/xid/0b0keq7yl5a-cs2zy3


https://wolfram.com/xid/0b0keq7yl5a-hpmt


https://wolfram.com/xid/0b0keq7yl5a-dmok3u

Covariance and Correlation are the same for standardized vectors:

https://wolfram.com/xid/0b0keq7yl5a-bwn1ui

https://wolfram.com/xid/0b0keq7yl5a-bhgwb3


https://wolfram.com/xid/0b0keq7yl5a-7gmaf

The covariance of a list with itself is the variance:

https://wolfram.com/xid/0b0keq7yl5a-cnm6n0

The diagonal of a covariance matrix is the variance:

https://wolfram.com/xid/0b0keq7yl5a-evvxao

https://wolfram.com/xid/0b0keq7yl5a-qppaj


https://wolfram.com/xid/0b0keq7yl5a-ydmht

The covariance tends to be large only on the diagonal of a random matrix:

https://wolfram.com/xid/0b0keq7yl5a-bo1p6w

Wolfram Research (2007), Covariance, Wolfram Language function, https://reference.wolfram.com/language/ref/Covariance.html (updated 2024).
Text
Wolfram Research (2007), Covariance, Wolfram Language function, https://reference.wolfram.com/language/ref/Covariance.html (updated 2024).
Wolfram Research (2007), Covariance, Wolfram Language function, https://reference.wolfram.com/language/ref/Covariance.html (updated 2024).
CMS
Wolfram Language. 2007. "Covariance." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2024. https://reference.wolfram.com/language/ref/Covariance.html.
Wolfram Language. 2007. "Covariance." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2024. https://reference.wolfram.com/language/ref/Covariance.html.
APA
Wolfram Language. (2007). Covariance. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/Covariance.html
Wolfram Language. (2007). Covariance. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/Covariance.html
BibTeX
@misc{reference.wolfram_2025_covariance, author="Wolfram Research", title="{Covariance}", year="2024", howpublished="\url{https://reference.wolfram.com/language/ref/Covariance.html}", note=[Accessed: 01-April-2025
]}
BibLaTeX
@online{reference.wolfram_2025_covariance, organization={Wolfram Research}, title={Covariance}, year={2024}, url={https://reference.wolfram.com/language/ref/Covariance.html}, note=[Accessed: 01-April-2025
]}