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.

  • $\begingroup$ Can you sample on the simplex and then throw out the result if it doesn't fall within the cube? Or is that impractical for the values of $n, k$ you're interested in? $\endgroup$ Commented Oct 5, 2021 at 16:11
  • 1
    $\begingroup$ I could sample from the simplex but the ratio between the measure of the simplex and the intersection goes to zero for $k\rightarrow 0$ or $n$ so in those cases there would be a lot of trials to do before getting a sample on the spot $\endgroup$ Commented Oct 6, 2021 at 5:30
  • $\begingroup$ cs.stackexchange.com/q/160050/755 $\endgroup$
    – D.W.
    Commented May 9, 2023 at 4:42


You must log in to answer this question.