02-24-2011 04:51 PM
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.
02-24-2011 04:55 PM
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.
02-24-2011 05:00 PM
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.
02-25-2011 01:55 AM
Depending on how strict your "equal distribution" requirement is, you may be able to simply use:
This is a histogram of the result for 100K iterations:
Note that the 120 and 180 values occur about half as often as the other values.
steve
02-25-2011 02:50 AM - edited 02-25-2011 02:50 AM
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: