# Sampling uniformly from the standard n simplex with further constraints

I would like to uniformly generate weights for n different objects. I understand this is the same as sampling from the Dirichlet distribution with alpha = 1 or sampling uniformly from the standard n-simplex which i can do in the same way as covered here: Generate uniformly distributed weights that sum to unity?

If I wanted to add further constraints, such as maximums and minimums for each weight, is there a way I can do this without repeatedly sampling until the values fall within my constraints?

You need to sample your weights from Dirichlet distribution and then simply transform them, by taking $x' = a + x \cdot (b - a)$, where $a$ is the new minimum and $b$ is the new maximum. Now your $x'$ values have $(a, b)$ bounds instead of $(0,1)$.