I am trying to generate random points on an n-dimensional unit sphere that satisfy a number of linear inequalities (a point $v \in \mathbb{S}^N$ has to satisfy $v \cdot x \geq v \cdot x_k$ for all $x_k$ in some list of vectors; the set of such v
's is non-empty). The distribution has to be uniform on the region defined by the linear constraints. The following code defines a region to sample as an intersection of a bunch of half-spaces and a sphere. It works as expected when the number of half-spaces (numPts - 1
) is small, and stops returning when the number of half-spaces gets large. Since there is no error message, I am having trouble diagnosing the problem. I am on version 12.1.0.0.
Clear["Global`*"];
SeedRandom[0];
numDims = 15;
numPts = 200; (*works*)
(*numPts = 700; (*does not work*) *)
y = RandomReal[1, numDims];
xs = RandomPoint[Simplex[numDims], numPts];
vs = Dot[xs, y];
j = Ordering[vs, -1][[1]];
x = xs[[j]];
rest = Delete[xs, j];
hs = Table[HalfSpace[rest[[k]] - x, 0], {k, 1, Length[rest]}];
reg = Fold[RegionIntersection, Region[Sphere[numDims]], hs];
samplePts = RandomPoint[reg, 10]
I saw a recent related post that suggested using DiscretizeRegion
, but I could not get that to work. I also tried using ImplicitRegion
without success.
I am trying to get the sampler to work reliably for around 1000 half-spaces.
ConicHullRegion
first? $\endgroup$