Random Number Generator: Difference between revisions

Jump to navigation Jump to search
[unchecked revision][unchecked revision]
Content deleted Content added
Add Wichmann-Hill
→‎Wichmann-Hill: Link the original paper
Line 169: Line 169:


=== Wichmann-Hill ===
=== Wichmann-Hill ===
In 1982, Brian Wichmann and David Hill proposed to combine three linear congruential generators, then normalizing and summing the results to get a number uniformly distributed between 0 and 1. A common instance is:
In 1982, Brian Wichmann and David Hill [https://doi.org/10.2307/2347988 proposed] to combine three linear congruential generators, then normalizing and summing the results to get a number uniformly distributed between 0 and 1. A common instance is:


<source lang="c">
<source lang="c">
Line 178: Line 178:
seed[2] = (170 * seed[2]) % 30323;
seed[2] = (170 * seed[2]) % 30323;
return fmod(seed[0] / 30269.0 + seed[1] / 30307.0 + seed[2] / 30323.0, 1.0);
return fmod(seed[0] / 30269.0 + seed[1] / 30307.0 + seed[2] / 30323.0, 1.0);
}
}</source>
</source>


This version is known to have a period of just shy of of seven trillion (the least common multiple of 30268, 30306, and 30322).
This version is known to have a period of just shy of of seven trillion (the least common multiple of 30268, 30306, and 30322).