3 ms·
To make a dice roll uniform, wouldn’t it be easier to do randomNumber % 8 and only use it if it is from 0 to 5, and discard and re-roll otherwise? (Since we ca
by teddyh 6y ago
To make a dice roll uniform, wouldn’t it be easier to do randomNumber % 8 and only use it if it is from 0 to 5, and discard and re-roll otherwise?
(Since we can reasonably assume that randomNumber is a binary number, and thus would be balanced over 8 values instead of 6.)
- lsc36 6y agoThat depends on the modulus being divisible by 8, which is not always the case. A common example is modulus = 2^31 - 1 [0] which is prime. [0] https://en.wikipedia.org/wiki/Linear_congruential_generator#Parameters_in_common_use https://en.wikipedia.org/wiki/Linear_congruential_generator#...