"Very" high dimensional convex hulls
Show older comments
I am trying to generate points that are uniformly distributed over a convex hull in a high dimensional space.
What I have as input is a set of N points in D dimensions. I want to sample uniformly over the convex hull of this set points. The best solution that I have found so far is by using Matt Jacobson's "vert2lcon" (file 30892 on the FEX) to convert from vertex representation to a linear constrain representation (i.e. inequalities defining the facets of the hull), and then to use Tim Benham's "cprand" (file 34208 on the FEX) to sample uniformly over the hull.
This works great for a few dimensions, however, the hull's that I am interested in are very high dimensional, somewhere between 30-60 dimensions usually. When I try to use vert2lcon on all D~30 dimensions MATLAB crashes. The reason is that vert2lcon constructs the convex hull of my points by calling "convhulln", which in turn calls "Qhull", and the crash report says that the error is happening during the mex function for "Qhull". My guess is that it can't handle that many dimensions.
Any suggestions?
I have thought of trying to take a subset of the dimensions at a time, but I'm not sure that that would work (thought about the example of a sphere, if you take the one dimensional orthogonal projections, and compute their convex hulls you get three lines parallel to the coordinate axes, the 3D convex hull of these convex hulls is going to be an octahedron so it definitely doesn't reproduce the sphere).
7 Comments
Oliver
on 29 May 2013
Oliver
on 30 May 2013
Oliver
on 30 May 2013
Oliver
on 30 May 2013
Oliver
on 30 May 2013
Matt J
on 30 May 2013
I did this in python using cvxopt with less then 170 lines of code (including I/O)
Does this mean you already have a solution that you like? What is the status of the problem?
Oliver
on 30 May 2013
Accepted Answer
More Answers (2)
Matt J
on 30 May 2013
Here's another possibility based on linear programming and separating plane ideas. Define
A=bsxfun(@minus, V,y(:));
f=sum(A,1);
A separating hyperplane exists if there is a vector, x satisfying
A*x<=0
f*x<0
which can be found by running a linear program solver with objective f*x and constraints A*x<=0 until a feasible solution satisfying f*x<0 is reached. This would probably require just one iteration of LINPROG starting at the initial feasible point x0=0 and using the 'active set' algorithm option.
11 Comments
But I'm unsure what the meaning of the second constraint "f*x<0" means?
It's mainly to ensure that you find a solution x which is not zero. The point x=0 is always a trivial solution to A*x<=0 and does not tell you anything about separability.
By choosing f=sum(A,1), it ensures that not only will x satisfy A*x<=0, but also that A(i,:)*x<0 (strict inequality) for at least one i, which should always be satisfied by any separating hyperplane as long as the convex hull is solid in R^D.
I'm assuming you know your convex hull to be solid, i.e., not confined to a hyperplane in R^D. Otherwise, the probability of landing in it when sampling from the larger hypercube will be zero.
Oliver
on 31 May 2013
Oliver
on 31 May 2013
am I correct in assuming that if the matrix containing the hull points has full rank then it is solid?
Not exactly. You need to test that the rank of this matrix is D
Q=bsxfun(@minus,V(2:end,:), V(1,:));
The point being subtracted V(1,:) is arbitrary. It can be any of the hull points. BTW, there are occasionally issues with Matlab's RANK function, so you're taking your chances by using it. It uses funny thresholding strategies. I use a different rank calculation approach in VERT2LCON.
I suppose it is possible that the convex hull of the points is very small, or very close to being a plane or line (nearly coplanar or colinear points), but is there any way to test for that?
I think you need to work in a transformed space where your hypercube fits as snugly as possible around the hull. How about this. Manipulate your hull samples as follows
X=bsxfun(@minus,V(2:end,:), V(1,:)).';
[r,idx,T]=lindep(X); %a sub-function in lcon2vert.m
if r<D, error 'Convex hull is not solid'; end
X=(T\X).';
cube_bounds=[min(X).',max(X).'];
Now, apply the sampling method to the transformed hull data, X, and using the hypercube bounded by the data in cube_bounds. You can untransform your samples at the end if you want,
samples=bsxfun(@plus, samples*T.', V(1,:));
Matt J
on 31 May 2013
You're right. You should leave V(1,:) in there.
I'm starting to have doubts that this hypercube idea is going to work, thoug :-(
The problem is that the ratio between the volume of a polyhedron and its bounding hypercube can get exponentially smaller in higher dimensions. You could need a vast amount of samples to have a probability of landing in the polyhedron in 34D. You can test this by trying a solid unit simplex
V=eye(D+1,D)
for larger and larger D and with the unit hypercube bounding it. I'll bet you'll see your percentage of hits fall off exponentially fast. Here's more evidence
s=@(D) eye(D+1,D);
v=1;
for D=2:20;
[~,v(D)]=convhulln(s(D));
end
plot(v)
Oliver
on 31 May 2013
Oliver
on 31 May 2013
in particular I used the points that define the hull as my samples, and in 34D it said that none of the points that define the hull are inside of it! What is going on?
Only points strictly in the interior of the polyhedron will fail the separation criterion f*x<0.
Also, one can only ever hope to distinguish between points that are either strictly in the interior of the polyhedron or strictly in the exterior. Boundary points can never be reliably tested by any method because floating point errors can make them look either slightly inside or slightly outside the polyhedron.
BTW, you should also be setting MaxIter=1. You probably also need some upper and lower bounds, e.g. lb=-ones(D,1), ub=-lb.
Matt J
on 29 May 2013
Taking random convex combinations of the vertices V(i,:) like in the following definitely won't work?
W=rand(M,N);
W=bsxfun(@rdivide,W,sum(W,2));
samples=W*V; %rows of V are the vertices.
6 Comments
This convex hull is smaller and fully contained within the unrestricted hull. I want to quantify how much smaller and what it "looks" like.
Even if you could find the t-space convex hull, how would you quantify its size and shape? Is it of lower dimension than the c-space hull? CONVHULLN could normally be used to measures its volume, but if it is high-dimensional like the c-space hull, then you will have the same problem running it through CONVHULLN as in c-space.
On the other hand, if the set in t-space lies in a significantly lower-dimensional manifold, then the best approach might be to sample t-space instead. You could solve an inverse problem to see if a sample point in t-space maps from the c-space convex hull and discard it otherwise. To evaluate this approach, it would help to see the form of the c-->t mapping. Is it linear, for example?
Oliver
on 4 Jun 2013
Matt J
on 4 Jun 2013
OK, glad you found a solution!
Categories
Find more on Bounding Regions in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!