dism()

Description:

Calculate Mahalanobis distance between two vectors on covariance matrix.

Syntax:

dism(X,Y,C)

Note:

The function computes Mahalanobis distance between vector X and vector Y on covariance matrix C. Both the vectors and the covariance matrix should be of same dimension. That is, if the covariance matrix consists of multiple 4-dimensional vectors, the vectors need to be 4-dimensional too.

Parameters:

X/Y

Vectors of same dimension with a specified covariance matrix

C

A covariance matrix

Return value:

Numeric value

Example:

 

A

 

1

[[8,2],[-3,9],[10,-3]]

 

2

[0,-2]

 

3

[1,2]

 

4

=covm(A1)

Calculate A1’s covariance matrix

5

=dism(A2,A3,A4)