Originally posted by Dirk Schreckmann:
Cast it to int and get [0,5] which is the same as [0,6) when considering only whole numbers.
Is this true?
giddee up
Originally posted by Ellen Fu:
This is True.
Originally posted by Don Liu:
I believe for a random int in [0, 6), you will more often get 5 than a random int in [0,5].
The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Originally posted by Dirk Schreckmann:
Don, it would seem to me that you are arguing that by multiplying a uniform distribution by some constant (so to speak), the distribution suddenly becomes unevenly distributed. Why do you think so?
Does this return a random value between 1 and 6 or between 1 and 7??
private int throwDice(){
return 1+(int)(Math.random()*6);
"I'm not back." - Bill Harding, Twister
Originally posted by Don Liu:
For a random number in [0, 5), assume we round the random number to closest int, same below. We have 20% chance to get 1, 2, 3, and 4. 10% to get 0 and 5.
The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Did you see how Paul cut 87% off of his electric heat bill with 82 watts of micro heaters? |