-
Notifications
You must be signed in to change notification settings - Fork 97
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Check that the matrix of (Sq)Mahalanobis is positive-definite? #174
Comments
I encountered this issue because I tried to take advantage of A warning in the README or documentation would be much appreciated. For example,
I'm not sure about enforcing positive (semi)definiteness. Checks like |
As mentioned above, the computations in Distances are valid if Q is symmetric. In contrast to positive (semi-)definiteness, this should be easy to check. |
Not exactly: we do take the max with 0 in |
Yeah, I changed this in #180 some time after I had opened the issue here, so initially only symmetry was assumed. |
Currently, upon creation of
(Sq)Mahalanobis(Q)
it is not checked ifQ
is actually positive (semi-)definite, and hence in particular symmetric, as shown in the following example:However, the implementation of
pairwise!(::SqMahalanobis, X, Y)
is based on the identity(x-y)'*Q*(x-y) = x'*Q*x + y'*Q*y - x'*Q*y - y'*Q*x = x'*Q*x + y'*Q*y - 2 * x'*Q*y
which holds only ifQ
is symmetric.This leads to the surprising behaviour
although
Hence, due to the missing check and the inconsistencies in
pairwise!
, I am a bit worried that users might not be aware of these assumptions and their impact onpairwise!
and might silently obtain incorrect values (see also JuliaGaussianProcesses/KernelFunctions.jl#154 (comment)).Maybe it would be best to check if the matrix of (Sq)Mahalanobis is positive-definite in the constructor? Or at least mention this assumption prominently in the README? Alternatively, one could neglect the mathematical motivation completely and make the results consistent by not assuming symmetry in the
pairwise!
computations, i.e., one could just calculatex'*Q*x + y'*Q*y - x'*Q*y - y'*Q*x
.The text was updated successfully, but these errors were encountered: