# covarianceMatrix

These functions allow efficient calculation of the Pearson, Spearman and Kendall correlation matrices and the covariance matrix respectively. They are optimized to avoid computing certain values multiple times when computing correlations of one vector to several others.

Note: These functions are only available when SciD is installed and dstats is compiled with version=scid.

1. SymmetricMatrix!double covarianceMatrix(RoR mat, TaskPool pool = null)
version(scid)
SymmetricMatrix!double
covarianceMatrix
(
RoR
)
(
RoR mat
,
)
if (
isInputRange!RoR &&
isInputRange!(ElementType!RoR)
&&
is(ElementType!(ElementType!RoR) : double)
&&
!isInfinite!RoR
)
2. void covarianceMatrix(RoR mat, ref Ret ans, TaskPool pool = null)
3. SymmetricMatrix!double pearsonMatrix(RoR mat, TaskPool pool = null)
4. SymmetricMatrix!double spearmanMatrix(RoR mat, TaskPool pool = null)
5. SymmetricMatrix!double kendallMatrix(RoR mat, TaskPool pool = null)

## Parameters

mat
Type: RoR

A range of ranges to be treated as a set of vectors. This must be a finite range, and must be rectangular, i.e. all elements must be the same length. For Pearson correlation and covariance, the ranges must also have elements implicitly convertible to double. SciD matrices can be treated as ranges of ranges and can be used with these functions.

## Examples

```1 auto input = [[8.0, 6, 7, 5],
2               [3.0, 0, 9, 3],
3               [1.0, 4, 1, 5]];
4 auto pearson = pearsonMatrix(input);
5 assert(approxEqual(pearson[0, 0], 1));```