1

I want to create an evenly distributed set of $N$ points inside a d-dimensional simplex ($d>3$), i.e. I want to have $N$ vectors $\vec{a}=\{a_1,a_2,...,a_d\}$ such that $0\leq a_j \leq 1$ for all $1\leq j\leq d$, and $a_1+a_2+...+a_d= 1$. For being specific, let's assume I want 10.000 points inside a 4-dimensional simplex. How can I do this?

For dimensions $d\leq 3$ I found a great answer here. In this low-dimensional case I also know of the package NDSolve\`FEM\` from which I could use the function ToElementMesh to create a set of points inside the simplex. However, this also only seems to work for $d\leq 3$ and for $d>3$ it raises an error -- Message text not found --.

I could of course simply generate pseudo-random numbers using RandomReal[] which would satisfy $a_1+a_2+...+a_d= 1$, however, they would probably not be evenly distributed.

Any ideas how I could implement this? All suggestions are appreciated.

Tobias95
  • 13
  • 2
  • 1
    If you need random points, evenly distributed in the simplex, you can use RandomPoint[Simplex[{{1, 0, 0, 0}, {0, 1, 0, 0}, {0, 0, 1, 0}, {0, 0, 0, 1}}]]. – Domen Jan 26 '24 at 11:43
  • Thanks, that's probably what I needed. Could you give this as an answer so I can accept it? – Tobias95 Jan 26 '24 at 12:06
  • Or do you need them equally spaced on a rectangular grid? – Domen Jan 26 '24 at 12:06
  • No, randomly distributed is totally fine. But out of curiosity, do you also have an idea for solving it on a rectangular grid? – Tobias95 Jan 26 '24 at 12:09

1 Answers1

1

Use RandomPoint on Simplex:

RandomPoint[Simplex[{{1, 0, 0, 0}, {0, 1, 0, 0}, {0, 0, 1, 0}, {0, 0, 0, 1}}]]
(*  {0.391776, 0.0488213, 0.410239, 0.149163} *)

Total[%] (* 1. *)

Domen
  • 23,608
  • 1
  • 27
  • 45