Currently, dice generation code for the Mersenne twister random number
generator looks like this :
dice = 1 + (int)(6.0 * genrand_int32(&rngctx->mti, rngctx->mt) /
(0xFFFFFFFF + 1.0));
that is, the rng provides a random integer between 0 and 2^32-1 and it is
mapped to a value between 1 and 6.
The trouble is that, since 2^32 is not a multiple of 6, a bias is
introduced and we get 715827883 aces, deuces, fours and fives for
715827882 threes and sixes...
Some of the other rngs implemented in gnubg have a similar problem.
It is certainly unnoticeable in practice from the rolls stream, but it
wouldn't hurt to avoid this.
Are there list members who are knowledgeable on rng robustness and could
confirm that, if one starts with a "good" rng for integers uniformly
distributed between 0 and n and discards any occurence of the top p
values, one gets a good rng for the [0, n-p] interval ?
Intuitively, it is tempting to say : "yes, and it is a condition for the
original generator being any good" but I'm afraid it may be a treacherous
domain.
_______________________________________________
Bug-gnubg mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/bug-gnubg