pythonic way to sample a point from a hyperplane of an euclidean space.

42 Views Asked by At

Consider the 8-dimensional euclidean space $\mathbb R^8$. I denote a point in $\mathbb R^8$ by

$$(a_1,a_2,a_3,a_4,b_1,b_2,b_3,b_4)$$

I want to sample a point from a convex subset $S$ of $\mathbb R^8$, where $S$ is defined by five equations and one inequality (it is indeed convex)

$$ \begin{cases} a_1+a_2+a_3+a_4&=0.9\\ b_1+b_2+b_3+b_4&=0.9\\ a_1+a_2-b_1-b_2&=0\\ a_3-b_3&=0\\ a_4-b_4&=0\\ a_1-b_1&\ge0 \end{cases} $$

($0\le a_i, b_i\le 1$)

I want to sample a point from $S$ randomly, I mean,like from uniform distribution. Is there any way to achieve this using python?

Note 1) One way to find such a point is to use linear programing(scipy.optimize.linprog). That is, make an arbitrary set of coefficients $w_i$'s (which is easy in python) to make an arbitrary (linear) objective function : $$f(a_1,a_2,a_3,a_4,b_1,b_2,b_3,b_4) = w_1a_1+w_2a_2+w_3a_3+w_4a_4+w_5b_1+w_6b_2+w_7b_3+w_8b_4$$ Then, use linear programming to find the point $x_0$ where the objective function attains its minimum. Since, the optima of linear programing problem happens on the boundary of the domain, we found a point $x_0$ in $S$. But such an $x_0$ is on the boundary, not in the interior of the domain. And I think it is not a good ways to get rich set of arbitrary points in $S$.

(After finding such boundary points, I can make a convex combination of them, to make an interior point of $S$. (Convexity of $S$ can be used here). But I think there are more general way to sample a point.)

Note2) The equations are too simple. For example, the fourth and fifth equation is just $a_3=b_3$ and $a_4=b_4$. But the equations can be more general (still linear). So instead of substituting $b_3$ by $a_3$ and $b_4$ by $a_4$ or so to reduce the problem to that of deciding three independent variables, I want to literally sample from the set $S$.