I am using scipy.spatial.distance.mahalanobis to calculate distance between two vectors but i'm getting null values for some vector I don't know why? null value is possible?


1 Answer 1


It is important to include your test cases when you encounter a potential bug.

Without further information, looking at the formula of Mahanologis distance. $$\sqrt{(u-v)^TV^{-1}(u-v)}$$ It is possible to obtain an error if $V$ is not positive definite as the input for the square root might be negative.

  • $\begingroup$ yes right exactly that's what happened in my case, thanks $\endgroup$ Commented Apr 15, 2019 at 5:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.