In somehow I need an random function that can generate highly uniform numbers, such as, when I say [5,5], and I run this function for 10 times, I would like to have 5 number that are less than 0.5 and other 5 numbers are greater than 0.5.
Every run should be separated, like:
for i in range(0,10):
rnd=random_function([6,3,1])
print rnd
After having run this function for ten times, then I have 6 numbers are less than 0.6, 3 numbers are between 0.6 and 0.9, and 1 number are between 0.9 to 1.
Does anyone know how can I do that? Because the random function inside python is not that uniform…. Thanks!!
What you are asking for is not random; indeed, it is fairly structured. The point of random data is that it isn’t structured: you can’t say anything about what the values will be, only what they will be on average.
You can still do what you want, though: just specify the ranges you want your numbers to fall into.
Explanation:
Given
(6,3,1), work out their sum (10). We want six numbers between 0 and 6/10, three numbers between 6/10 and 6/10 + 3/10, and one number between 6/10 + 3/10 and 6/10 + 3/10 + 1/10. We can generate these by calling