LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

random numbers addition 1


@ziedhosni wrote:

Sorry for the mistake,I mean with this the last solution suggesting to do the sum then divide each number by the sum. This is what I am using before asking the question


The numbers will have all a flat probability between zero and 1/N. That is not low variance by any definition. Your problem description does not specify the random range of individual numbers, so this seems like a valid solution.

Message 21 of 38
(1,103 Views)

The problem you are not asking for a random number is. Since your are forcing a situation on the set of random numbrs, you wil not get a uniform distribution on it any more, thus it will fail the normal random test number test. As you mention, the low variance is an indication. Random numbers do not have your constrain. Another issue, is that you are looking at too low number of random numbers, 5 is insufficient. Generally they are looking at a lot more. If you want to use your method, you should consider generating millions of random numbers. Guess what, it will be very rare to have number > .1

Message 22 of 38
(1,097 Views)

I will ask the same question by another way: how can obtain 5 independant random numbers that their sum is equal or near to one and at leat one of them is greater than 0.6.

I have posted a VI called Random near to the solution but I am still not satisfied. Mathematically,it is very ugly.

To be clear, I am trying to mix different chemical reagents with different proportion and the total volume is fixed. If I use all the previous ideas I fall in the following problem: I mix the reagents with proportions near to each others:0.1 0.33 0.2 0.1 ..

0 Kudos
Message 23 of 38
(1,092 Views)

@ziedhosni wrote:

All the generated numbers are below 0.4. None of them reach 0.7 or 0.9.

See attached


  • Very few people have LabVIEW 2013, so you should convert to an earlier version before attaching.
  • Always mention the LabVIEW version of an attachment.
  • Please have the decency to give the VI a descriptive name. "Untitled 2.vi" is NOT a descriptive name.
  • If there is only a single VI, attach it directly without zipping it up first.

You still have not specified what you mean by "random". As others have said, if you want each random number to be between 0 and 1 and the sum should be 1, you are introducing a correlation between the numbers that no longer makes them random. For example if the first random number is 0.9, all following numbers need to be way below 0.1. You need much better specifications for the desired randomness!

Message 24 of 38
(1,086 Views)

Yes.  To have 1 number above .9, you'd need the other numbers to be below .1 in sum total.  There is a 10% chance of any given number to below .1.  For 4 numbers to sum below .1, then you'd have probably a 1 in 10,000 chance.  Actually perhaps far greater odds.

Message 25 of 38
(1,077 Views)

Then try my solution, atleast you have 50% probability of the 1st number being >0.5 😉

/Y

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

Qestit Systems
Certified-LabVIEW-Developer
Message 26 of 38
(1,075 Views)

RavensFan wrote:


eyeballxxx wrote:


As an aside, random numbers with uniform distribution like to cluster. Think of a Gaussian bell.


Can you post some sort of reference that supports that statement?

Uniform distribution means any given value has as likely chance of occurring as any other.  There is no Gaussian bell and there is no clustering.


 

I wasn't professing any kind of number theory backing, just speaking from experience that with a low sample volume you tend to get clusters. It's clear as you increase the samples the uniformity becomes more evident. 

Message 27 of 38
(1,069 Views)

There are 2 psuedo random process (I used the term loosely) you could use:

1.  use a uniform number to pick the first number (0 - 1)

     a. get another random number between 0 and 1. If the sum less than 1 use if not go pick another

     b. repeat until the fifth number. use the remainder

2. Use a uniform rand number generator (0 - 1), a

     a. pick a another random number between (0 - [1 - a]), b

     b. pick another random number between ( 0 - [ 1 - a - b]), continune until 4 numbers

     c. use the remainder for the fifth number

 

You can use different variations of 1 and 2 or other, e.g. reverse the the order.

Message 28 of 38
(1,064 Views)

Ok let me say to be specific semi-random if the term exist. I need variables where sum is equal to 1 and have a high variance. So if I generate 5 numbers, I have a mean equal to 0.2.

Good numbers: 0.1 0.6 0.01 0.15 0.14

Bad numbers: 0.22 0.31 0.1 0.15 0.22

 

Sorry for people cannot read tjhe vis

 

0 Kudos
Message 29 of 38
(1,057 Views)

Another possibility would be to skew the random numbers heavily before normalizing. For example the following code will give you typically one relatively large number.

 

 

Message 30 of 38
(1,055 Views)