I\'m generating random numbers from 1 to 20 by calling generateRandom()
. How can I exclude some values, say 8 and 15?
function generateRandom(mi
One way, which will maintain the generator's statistical properties, is to generate a number in [1, 18]. Then apply, in this order:
If the number is 8 or more, add 1.
If the number is 15 or more, add 1.
I'd be reluctant to reject and re-sample as that can cause correlation plains to appear in linear congruential generators.