Random sampling from the intersection of cube and simplex

77 Views Asked by At

I'm trying to find a way to randomly sample points from the intersection of the simplex $\Delta_k$, defined by \begin{equation} \Delta_k : \{x_i\in\mathbb{R}^n\ |\ 0\leq x_i\leq k, \ x_1+x_2+\cdots+x_n = k\} \end{equation} with $0\leq k \leq n$ and the unit cube defined by \begin{equation} \{x_i\in\mathbb{R}^n\ |\ 0\leq x_i \leq 1\ \} \end{equation} Now, I know how to obtain a uniform random sample on the simplex (e.g. from here https://cs.stackexchange.com/questions/3227/uniform-sampling-from-a-simplex) and the sampling is trivial on the cube, but how to tackle the intersection?

The intersection in some cases (i.e. for some values of $k$) is another simplex so the problem in those cases is solved, but for instance in the case $n=3$ and for some values of $k$ the intersection is a hexagon.