LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Five Random Number Generation between numbers 10-20

I want to generate 5 random numbers (U32) between a range of 120 and 180 with equal distribution. Can i do it? I tried using white noise generation VI, but it gives numbers from [-a,a].

 

Thanks in advance.

0 Kudos
Message 1 of 5
(4,404 Views)

Use an amplitude of 30 and add 150 to your result.

 

So you have 150 +/- 30.

 

You will want to use rounding or integer functions to give you an integer rather than a double precision floating point number.

0 Kudos
Message 2 of 5
(4,402 Views)

You need to specify whether the random numbers are normal, uniform, exponential, poison, etc. The way you generate the numbers is dependent on the distribution you specified.

0 Kudos
Message 3 of 5
(4,391 Views)

Depending on how strict your "equal distribution" requirement is, you may be able to simply use:

 

random 120 to 180.png

 

This is a histogram of the result for 100K iterations:

 

Histogram.png

 

Note that the 120 and 180 values occur about half as often as the other values.

 

steve

--------------------------------------------------------------------------------------------------------------------------
Help the forum when you get help. Click the "Solution?" icon on the reply that answers your
question. Give "Kudos" to replies that help.
--------------------------------------------------------------------------------------------------------------------------
0 Kudos
Message 4 of 5
(4,361 Views)

 


stevem181 wrote:

Note that the 120 and 180 values occur about half as often as the other values.


 

To correct that flaw, multiply by 61 and round to -infinity. For example like this:

 

Message 5 of 5
(4,352 Views)