Skip to content
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

Bug in qinfer.utils.in_ellipsoid ? #155

Open
sapristi opened this issue Jul 2, 2022 · 0 comments
Open

Bug in qinfer.utils.in_ellipsoid ? #155

sapristi opened this issue Jul 2, 2022 · 0 comments

Comments

@sapristi
Copy link

sapristi commented Jul 2, 2022

Hello,
I've been playing with QInfer for it's minimum volume enclosing_ellipse algorithm. It seems there is some bug with the in_ellipsoid function, for which no point used to compute the ellispoid are inside it.

Here's a snippet with the data I used. I have no idea whether it makes sense, but using A instead of it's inverse in the distance computation seem to give a better fit distance (although some points would still be outside of the ellispe).

import numpy as np
import qinfer

# 7 points in 8 dimensions
points = np.array([[9.61671088e+01, 3.09532270e+00, 3.59059099e+00, 3.52696730e+00,
        4.68305129e+00, 4.92967759e+01, 1.52589430e+00, 1.77004559e+00],
       [1.73990050e+02, 2.98332674e+00, 4.39375052e+00, 2.91588476e+00,
        4.07209379e+00, 3.55407545e+01, 1.06029683e+00, 1.56157208e+00],
       [2.37193968e+02, 9.17352808e-01, 1.35086160e+00, 7.16079767e-01,
        1.02764937e+00, 2.94583624e+01, 2.70237115e-01, 3.97941707e-01],
       [1.47826437e+02, 1.08761428e+00, 1.75354413e+00, 1.32319382e+00,
        2.81922693e+00, 3.98934693e+01, 4.33887070e-01, 6.99549591e-01],
       [6.32894555e+02, 2.45578343e+00, 3.75805515e+00, 8.68867797e+00,
        1.14160928e+01, 1.35298152e+01, 3.32262960e-01, 5.08457917e-01],
       [2.01686471e+02, 1.55523380e+00, 1.76140513e+00, 1.37662800e+00,
        1.55630744e+00, 3.27865510e+01, 5.09907521e-01, 5.77503991e-01],
       [1.86267513e+02, 2.65450049e+00, 3.72240851e+00, 3.18004405e+00,
        5.36798721e+00, 3.41711622e+01, 9.07073667e-01, 1.27199025e+00]])
A, c = qinfer.utils.mvee(points, 0.001)
print("in_ellipsoid?", [qinfer.utils.in_ellipsoid(p, A, c) for p in points])
print("distance", [
    np.einsum('j,jl,l', c-p, np.linalg.inv(A), c-p)
    for p in points
])
print("distance fixed?", [
    np.einsum('j,jl,l', c-p, A, c-p)
    for p in points
])

Output:

in_ellipsoid? [False, False, False, False, False, False, False]
distance [13612175772.118567, 5243680294.202738, 1343921122.9179094, 7623619437.438548, 34964549033.975334, 3221636117.3242393, 4282303012.8117304]
distance fixed? [1.140625, 0.6796875, 0.71484375, 1.26025390625, 0.3359375, 0.94921875, 0.931640625]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant