[Issue 10550] Xorshift32 and Xorshift160 do not generate uniformly-distributed random numbers
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Fri Jul 5 08:12:24 PDT 2013
http://d.puremagic.com/issues/show_bug.cgi?id=10550
--- Comment #4 from Joseph Rushton Wakeling <joseph.wakeling at webdrake.net> 2013-07-05 08:12:24 PDT ---
Uniformity in Xorshift160 can be restored by tweaking the update rules:
else static if (bits == 160)
{
temp = seeds_[0] ^ (seeds_[0] >> a);
seeds_[0] = seeds_[1];
seeds_[1] = seeds_[2];
seeds_[2] = seeds_[3];
seeds_[3] = seeds_[4];
seeds_[4] = seeds_[4] ^ (seeds_[4] >> c) ^ temp ^ (temp >> b);
}
... which faithfully reproduce what is given at the bottom of p.4 of the paper,
and changing the first line to:
temp = seeds_[0] ^ (seeds_[0] << a);
Note that this change was pure guesswork on the grounds that other bit-values
of the algorithm had this alternative formulation. It also results in a
failure of the unittest on line 1032 of std.random.
Unfortunately George Marsaglia has died, so we can't ask him about typos in his
papers. :-( I was not able to find any erratum to the published article, but
the discrepancies already identified make me suspect that it must be in error
in several places.
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list