09-03-2013 05:23 AM
Hello,
Please can you help me to generate a serie of independant random number, their sum should be equal to one and able to reach the extremities.
I give 2 examples of a serie of 5 number
0.1 0.6 0.01 0.2 0.09 =1
0.01 0.01 0.05 0.02 0.91 =1
I have a VI attached able to generate these random numbers but they are very near to each others. I give an example
0.3 0.2 0.1 0.35 0.05 =1
Thanks,
09-03-2013 06:31 AM
The 1st is random 0-1, the second is 0-(1-all previous) and so on, until the 5th, which is the remainder.
/Y
09-03-2013 06:58 AM
Thanks for your answer. This was the solution I suggested but when I asked an expert in mathematics, the random numbers are not independant and each one will be dependant of the previous ones.
09-03-2013 07:45 AM
Your main problem is that the mean of your samples must be 1/N, where N is the number of samples. This will lower what you can get for an upper extreme. I'd talk to your math expert and ask him for an algorithm that can do this and then we can code it up.
09-03-2013 08:09 AM
I do not see how all the random numbers can be independent when the sum is constrained. For a series of N numbers N-1 can be independent but the nth value is deterministic, not random as Yamaeda pointed out.
If you allow the sum to have some range of values near 1, then you might be able to get what you are asking.
How do you define "independence" in a case like this?
Lynn
09-03-2013 08:15 AM
Thank you for your interest. I am looking for the idea of getting this random number under these conditions. Then, I can code it up by myself.
It is right the mean will be 1/N but I want to obtain numbers with high variance like in the example above.
09-03-2013 08:19 AM
Actually, only the first number is independent. All remaining are dependent on the sum of the previous for their possible range, and the last is directly dependendent on the sum of the previous.
So
V0= random(0 to 1)
Vi (for i=1 ..... n-1)= random(0 to sum(V0 to Vi-1)
Vn = 1- sum(V0 to Vn-1)
09-03-2013 08:31 AM - edited 09-03-2013 08:35 AM
How strict are your timing requirements?
A bruteforce method would continually generate arrays of "independent" random numbers until the sum of the array equals one. Using the rand(0-1) will take quite a long time particularly as you increase the length of the series, N.
[EDIT: probably shouldn't try running this for N>about 5 or 6]
09-03-2013 08:32 AM
Number 2-4 are independant within their range, which is dependant. 🙂
/Y
09-03-2013 08:35 AM
Thanks a lot but I feel I returned to the starting point.
Until now, I have a vi that generate normal rndom number. I sum them then I divide each one by the sum. So they are fully independand. The unique problem is that the numbers have a very low variance.