Correlation
✖
Correlation

gives the (i,j) correlation for the multivariate symbolic distribution dist.
Details


- Correlation is typically used to measure covariation, i.e. whether one variable tends to vary similarly to another.
- For vectors, the correlation estimate Correlation[v,w] is given by
with σv w=Covariance[v,w] and σv=StandardDeviation[v].
- The correlation
is a normalized covariance with
.
- For matrices
and
with dimensions
and
and columns indexed as
and
, respectively, Correlation[a,b] is a
matrix with elements given by
:
- where Σa b=Covariance[a,b] and σa=StandardDeviation[a] etc.
- For a matrix a with
columns, Correlation[a] is a
matrix given by Correlation[a, a].
- Correlation works with any vector that is VectorQ or matrix that is MatrixQ.
- Correlation[dist,i,j] gives Covariance[dist,i,j]/(σi σj), where σi=StandardDeviation[dist]〚i〛.
- Correlation[dist] gives a correlation matrix with the (i,j)
entry given by Correlation[dist,i,j].



Examples
open allclose allBasic Examples (3)Summary of the most common use cases
Correlation between two vectors:

https://wolfram.com/xid/0bimg2hm-bgsw6i


https://wolfram.com/xid/0bimg2hm-ebsvf6

Correlation matrix for a matrix:

https://wolfram.com/xid/0bimg2hm-bobjfi


https://wolfram.com/xid/0bimg2hm-3zvd

Correlation matrix for two matrices:

https://wolfram.com/xid/0bimg2hm-de1ufn


https://wolfram.com/xid/0bimg2hm-ib0k4r

Scope (14)Survey of the scope of standard use cases
Data (8)
Exact input yields exact output:

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


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

Approximate input yields approximate output:

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


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

Correlation between vectors of complexes:

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


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

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

https://wolfram.com/xid/0bimg2hm-cce1ir


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


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


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

Find the correlation for data involving quantities:

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

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

Correlation between lists of dates:

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


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


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

Correlation between matrices of times:

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

Distributions and Processes (6)
Correlation for a continuous multivariate distribution:

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


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

Correlation for a discrete multivariate distribution:

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


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

Correlation controls the orientation and sharpness of a multivariate probability distribution:

https://wolfram.com/xid/0bimg2hm-djrchi

https://wolfram.com/xid/0bimg2hm-qd90y8

Correlation for derived distributions:

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


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

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


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

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


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

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

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

Correlation matrix for TemporalData at times and
:

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


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

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

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

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

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

Correlation can be used to measure linear association:

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

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

Correlation can only detect monotonic relationships:

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

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

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

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

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

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

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

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

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


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

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

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

https://wolfram.com/xid/0bimg2hm-ce9r5a

https://wolfram.com/xid/0bimg2hm-j71cv


https://wolfram.com/xid/0bimg2hm-b8mdab

https://wolfram.com/xid/0bimg2hm-bj1ijg

https://wolfram.com/xid/0bimg2hm-b703nn

Correlation and AbsoluteCorrelation agree for zero mean and unit marginal variances:

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

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


https://wolfram.com/xid/0bimg2hm-fi0mpw


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


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

SpearmanRho is Correlation applied to ranks:

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

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


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

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

CorrelationFunction for a process is the off-diagonal entry in the correlation matrix:

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

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


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


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

Correlation and Covariance are the same for standardized vectors:

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

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


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

The diagonal elements of a correlation matrix are equal to 1:

https://wolfram.com/xid/0bimg2hm-l00b5

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