08-10-2006 05:40 AM
08-10-2006 05:51 AM
Hi
That's just simple math:
Let's say x is a random value.
So you get dice = 1 + round(x*5)
08-10-2006 05:58 AM
08-10-2006 06:14 AM - edited 08-10-2006 06:14 AM
Just multiply by 6 and round to the next highest integer.
Choose the output that you want for your needs, integer or double.
Random is strictly between 0 and 1, but you might possibly want to make sure that rounding errors in the multiply haven't made the answer 7.
Rod.
Message Edited by Rod on 08-10-2006 12:16 PM
08-10-2006 06:20 AM
08-10-2006 06:31 AM
Errm, but if you multiply by 5 and convert the result to an integer, doesn't that give you a fencepost error??
Depending whether your conversion is to the integer above, below, or nearest you'd get no instances of 1, no instances of 6, or get 1 and 6 half as often as 2, 3, 4, or 5.
Rod.
08-10-2006 06:46 AM
08-10-2006 10:56 AM
@F. Pöck wrote:
Hello,
i found that "random number 0-1" feature in Labview, but how about
simulating a dice (1-6).
Best regards
f.pöck
If you multiply by 6, round down and add 1 you get the required result.
The attached VI (LV7.0) shows that the distribution is even between the 6 numbers.
Tim Norris
08-10-2006 02:32 PM
See the attached example for multiple dice rolls simulated
Paul
LV 7.0
08-10-2006 02:33 PM
Oops no attachment, here you go!
Paul