It's not due to the poor randomness of the C random(). It's because you divide a random variable by the SUM of N random variables. The variance changes (this may be also because one variable of the sum at the denominator is the variable at the numerator). I tried it even with BOOST libraries...
Yes, but the sum of N random variables is not a constant :wink:
By normalizing you get each variable as the result of a uniform random variable divided for a sum of uniform random variables.
I tried to "uniformize" the resulting variables by generating angles with a distribution such that there were more angles near π/4, but it didn't work properly. I think it was because each angle uses a certain combination of cos and sin in the conversion to cartesian coordinates. Maybe I should...
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...
Yes, easy but wrong. In fact if you look at the plot of sin and cos you see that there are more points in the codomain when sin and cos come near to 1.
My original idea was to find a distribution (not uniform) to generate these angles such that the result of sin and cos would be uniform. I...
Take the case with N=2
Generate v[0] as uniform[0,1]
Calculate v[1] as 1-v[0]
Result: 2 uniform variables (not independent but uniform)
If you plot the frequencies of the two variables, the plots are "flat". I mean each of the two variables is uniformly distributed. Obviously v[1] is uniform...
Hi chiro, thanks for the reply. If you generate N variables and then you divide by the total sum you no longer have N uniform random variables. If you try, you can see that the plot of the frequencies of a single variable is no longer "flat". I could try to use R, but only a question: can I...
Hi all, I'm trying to generate uniform random vectors with n dimensions.
To be more precise, each of the elements of the vector must be a uniform distributed variable in [0,1]
The constraint is that the sum of the elements of the vector must be 1.
I tried different solutions for over a week but...