# Correlation

Correlation[v1,v2]

gives the correlation between the vectors v1 and v2.

Correlation[m]

gives the correlation matrix for the matrix m.

Correlation[m1,m2]

gives the correlation matrix for the matrices m1 and m2.

Correlation[dist]

gives the correlation matrix for the multivariate symbolic distribution dist.

Correlation[dist,i,j]

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

# Details • Correlation[v1,v2] gives Pearson's correlation coefficient between v1 and v2.
• The lists v1 and v2 must be the same length.
• Correlation[v1,v2] is equivalent to Covariance[v1,v2]/(StandardDeviation[v1]StandardDeviation[v2]).
• For a matrix m with columns, Correlation[m] is a × matrix of the correlations between columns of m.
• For an × matrix m1 and an × matrix m2, Correlation[m1,m2] is a × matrix of the correlations between columns of m1 and columns of m2.
• Correlation works with SparseArray objects.
• Correlation[dist,i,j] gives Covariance[dist,i,j]/(σi σj), where σi is the i component of the standard deviation of dist.
• Correlation[dist] gives a correlation matrix with the (i,j) entry given by Correlation[dist,i,j].

# Examples

open allclose all

## Basic Examples(3)

Correlation between two vectors:

Real values:

Correlation matrix for a matrix:

Real values:

Correlation matrix for two matrices:

Real values:

## Scope(12)

### Data(7)

Exact input yields exact output:

Approximate input yields approximate output:

Correlation between vectors of complexes:

Works with large arrays:

SparseArray data can be used:

Find the correlation of WeightedData:

Find the correlation for data involving quantities:

### Distributions and Processes(5)

Correlation for a continuous multivariate distribution:

Correlation for a discrete multivariate distribution:

Correlation for derived distributions:

Data distribution:

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

Correlation matrix for TemporalData at times and :

## Applications(3)

Compute the correlation of two financial time series:

Correlation can be used to measure linear association:

Correlation can only detect monotonic relationships:

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

## Properties & Relations(7)

The correlation matrix is symmetric and positive semidefinite:

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

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

SpearmanRho is Correlation applied to ranks:

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

Correlation and Covariance are the same for standardized vectors:

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

Introduced in 2007
(6.0)
|
Updated in 2010
(8.0)