Mahalanobis distance
The Mahalanobis distance calculates the distance of the observed sample in the population sample, regardless of the dimension. dism(X,Y,C) computes Mahalanobis distance between vector X and vector Y on covariance matrix C.The number of samples should greater than the number of dimensions. For example, the same sample data as above, calculate the Mahalanobis distance.
A |
B |
|
1 |
[[22,7.25],[38,71.2833],[26,7.925],[35,53.1],[35,8.05]] |
[] |
2 |
=covm(A1) |
|
3 |
for A1 |
=A1.(dism(A3,~,A2)) |
4 |
>B1=B1|[B3] |
A1 Input the sample data
B1 Define an empty sequence to hold the results
A2 Calculate the covariance matrix for A1
A3:B4 Loop A1, calculate the Mahalanobis distance between the two samples, and store the result in B1. B1 returns the Mahalanobis distance matrix between the samples
SPL Official Website 👉 https://www.scudata.com
SPL Feedback and Help 👉 https://www.reddit.com/r/esProcSPL
SPL Learning Material 👉 https://c.scudata.com
SPL Source Code and Package 👉 https://github.com/SPLWare/esProc
Discord 👉 https://discord.gg/cFTcUNs7
Youtube 👉 https://www.youtube.com/@esProc_SPL