Skip to content
Prev 346031 / 398502 Next

Generate random numbers under constrain

You want random numbers within the n-dimensional simplex (sum xi <=1)
The easiest solution of course would be creating n-dimensions vectors
with iid uniform components on [0,1) and throwing away those
violating the inequality.
Since the volume of the n-dimensional simplex is 1/n! (factorial)
this becomes very wasteful even for low dimensions.

A possible  answer is to use the Dirichlet distribution from package lca)
since the uniform distribution on the simplex is a special case
of the Dirichlet distribution.