03-27-2015 09:18 PM
@Thomas_robertson wrote:
Good point. I'll bet I coded some randomize routines wrong in the past... So round down is always the right thing to do. NI should revamp the random number function such that you can type in a range.
That very idea was suggested on the Idea Exchange some time ago.
03-27-2015 09:45 PM
@Thomas_robertson wrote:
Good point. I'll bet I coded some randomize routines wrong in the past... So round down is always the right thing to do. NI should revamp the random number function such that you can type in a range.
The OpenG Numeric library has this already. You can add it from the VIPM. It will be called Random Number within Range
03-30-2015 10:40 AM
If you multiply by 3 and round down won't you get a number 0-3? If you then add one, you'll get 1-4. So what do you do to avoid the (rare) situation of getting 1.0000000 out of the random number generator?
03-30-2015 11:15 AM
@Thomas_robertson wrote:
If you multiply by 3 and round down won't you get a number 0-3? If you then add one, you'll get 1-4. So what do you do to avoid the (rare) situation of getting 1.0000000 out of the random number generator?
You won't. Just read the help.
"The number generated is greater than or equal to 0, but less than 1"
0<=x<1
So when you do a multiply by 3 and round down, you get 0 to 2.
03-30-2015 12:05 PM
@Thomas_robertson wrote:
If you multiply by 3 and round down won't you get a number 0-3? If you then add one, you'll get 1-4. So what do you do to avoid the (rare) situation of getting 1.0000000 out of the random number generator?
If you read what I wrote, 1.00000 is not returned by the random number generator. Is it 0.9999999.....