scipyqhull

Why does Qhull error when computing convex hull of a few points?


I'm trying to compute the convex hull of 9 points in 10 dimensional space. Through the scipy interface, I'm calling scipy.spatial.ConvexHull(points) and getting QH6214 qhull input error: not enough points(9) to construct initial simplex (need 12)

I think the definition of convex hull is well defined regardless of the dimension. What is going on here? Is there a different function I can call that might fix this?


Solution

  • Maybe projecting the points on a hyperplane before computing the hull will do the trick.

    Use for example the Principal Component Analysis class sklearn.decomposition.PCA from the scikit-learn toolkit, to reduce dimension.

    vertices = np.random.randn(9, 10)
    from sklearn.decomposition import PCA
    model = PCA(n_components=8).fit(vertices)
    

    You can now transform back and forth from your vertices to the projected using model.transform and model.inverse_transform.

    proj_vertices = model.transform(vertices)
    hull_kinda = ConvexHull(proj_vertices)
    hull_kinda.simplices
    

    This outputs something like this

    array([[6, 4, 3, 8, 0, 7, 5, 1],
           [2, 4, 3, 8, 0, 7, 5, 1],
           [2, 6, 3, 8, 0, 7, 5, 1],
           [2, 6, 4, 8, 0, 7, 5, 1],
           [2, 6, 4, 3, 0, 7, 5, 1],
           [2, 6, 4, 3, 8, 7, 5, 1],
           [2, 6, 4, 3, 8, 0, 5, 1],
           [2, 6, 4, 3, 8, 0, 7, 1],
           [2, 6, 4, 3, 8, 0, 7, 5]], dtype=int32)
    

    Use now the model.inverse_transform to get the simplices back in your 10 dimensions.