n=1+(int)(Math.random()*6);This is the old BASIC style. Use nextInt suggested by bbrita. It has better random properties.
While I agree that bbritta's version is better (and seems faster), how would it have better random properties?n=1+(int)(Math.random()*6);This is the old BASIC style. Use nextInt suggested by
bbrita. It has better random properties.
Pete, thank you for your exhaustiveWell, it's a theoretical argument with practical consequences. Using nextInt you get a more uniform distribution of random integers. It's still not "true" randomness but it's the closest you get with a standard API method so why not use it?
explanation.
In the context of the original question this is of
course a more or less theoretical argument. According
to Ulrica's post I had expected more direct
consequences.
Well, it's a theoretical argument with practicalAs a general rule, yes. Yet the practical consequences are well below any statistical significance. The bias that was described is one part in 2^53, but the maximum cycle length of the PRNG used is only 2^48.
consequences. Using nextInt you get a more uniform
distribution of random integers. It's still not "true"
randomness but it's the closest you get with a
standard API method so why not use it?