I'm using Pairwise Mahalanobis distance in R as code to calculate the Mahalanobis distance:
# express difference (X1-X2) as atomic row vector
d <- as.matrix(X1-X2)[1,]
# solve (covariance matrix) %*% x = d for x
x <- solve(cov(R),d)
# Mahalanobis calculation forced in two steps
Ma <- sum(d*x)
with X and Y as the individual vectors and R as the population covariance matrix. The distance itself is defined as:
And as far as I can see the square root is missing in the upper code. Right?
edit: To add some information: I have vectors with four parameters:
Device1:
Voltage Slope Voltage_irr Slope_irr
355 6.8 354.2 6.67
Device2:
Voltage Slope Voltage_irr Slope_irr
357.2 6.3 356.7 6.11
Device3:
(..)
Each vector represents a device and I want to estimate/calculate how similar the devices are to each other. I wonder now if there is a difference in using the squared Mahalanobis distance or using the root of the Mahalanobis distance.