Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Linear congruential generator
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
=== ''m'' a power of 2, ''c'' = 0 === Choosing ''m'' to be a [[power of two]], most often ''m'' = 2<sup>32</sup> or ''m'' = 2<sup>64</sup>, produces a particularly efficient LCG, because this allows the modulus operation to be computed by simply truncating the binary representation. In fact, the most significant bits are usually not computed at all. There are, however, disadvantages. This form has maximal period ''m''/4, achieved if ''a'' β‘ Β±3 (mod 8) and the initial state ''X''<sub>0</sub> is odd. Even in this best case, the low three bits of ''X'' alternate between two values and thus only contribute one bit to the state. ''X'' is always odd (the lowest-order bit never changes), and only one of the next two bits ever changes. If ''a'' β‘ +3, ''X'' alternates Β±1βΒ±3, while if ''a'' β‘ β3, ''X'' alternates Β±1ββ3 (all modulo 8). It can be shown that this form is equivalent to a generator with modulus ''m''/4 and ''c'' β 0.{{r|KnuthV2}} A more serious issue with the use of a power-of-two modulus is that the low bits have a shorter period than the high bits. Its simplicity of implementation comes from the fact that bits are never affected by higher-order bits, so the low ''b'' bits of such a generator form a modulo-2<sup>''b''</sup> LCG by themselves, repeating with a period of 2<sup>''b''β2</sup>. Only the most significant bit of ''X'' achieves the full period.
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)