LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

random numbers addition 1

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,

 

0 Kudos
Message 1 of 38
(3,655 Views)

The 1st is random 0-1, the second is 0-(1-all previous) and so on, until the 5th, which is the remainder.

/Y

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
Message 2 of 38
(3,641 Views)

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.

0 Kudos
Message 3 of 38
(3,631 Views)

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.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 4 of 38
(3,617 Views)

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

Message 5 of 38
(3,606 Views)

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.

0 Kudos
Message 6 of 38
(3,602 Views)

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)

Message 7 of 38
(3,600 Views)

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]

Message 8 of 38
(3,588 Views)

Number 2-4 are independant within their range, which is dependant. 🙂

/Y

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
Message 9 of 38
(3,587 Views)

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.

0 Kudos
Message 10 of 38
(3,579 Views)