chiro said:
You can't generalize like that.
Random number generators for many applications that are statistically sound can be implemented as code in any language and this includes C++. You just have to get the right algorithm with the right properties and use that.
You're absolutely right
Chiro, I'll explain myself, the C++
default RNG is a linear congruential generator which is very fast and useful for any non-statistically critical application. This kind of RNG perform poorly with tests checking for randomness and specially so in random vectors.
Which takes me to
3HeadedMonkey's issue in this thread and the flatness when dividing a uniform variable by a constant; since you divide by the sum this will be different each time and ,since some sums values will be more common than others, the resulting distribution for each dimension is not uniform anymore.
3HeadedMonkey said:
I have to think about this. If I want this, I can do it by repeatedly folding the hyperspace. I already coded it and it works. In this case the single elements are not uniform. But maybe the right thing to do.
I explain better the problem:
This vector is the input of an heuristic optimization algorithm, the random restarts are useful to find the global maximum. I want to restart in very random points (uniformly). So, I think that sampling the hyper-tetrahedron uniformly could be the best solution. Do you agree?
Oh, a random point, I see, then I disagree, if what you truly want is a random vector, your condition
"the sum of the components is one" is not going to give you that. This way of sampling will favor the vector
(1/N,...,1/N), and neither having uniform distributions in their components will give you that. You need these conditions for anything else?
For a uniform random vector of length one, that is, a vector equally likely to point at any direction, you need to sample a vector which components follow a standard normal distribution x_i \sim N(0,1) and then divide it by the length of the sampled vector \sqrt{x_1^2+x_2^2+...+x_n^2}