Recent from talks
Knowledge base stats:
Talk channels stats:
Members stats:
Multiply-with-carry pseudorandom number generator
In computer science, multiply-with-carry (MWC) is a method invented by George Marsaglia for generating sequences of random integers based on an initial set from two to many thousands of randomly chosen seed values. It involves simple computational integer-arithmetic, and leads to high-speed generation of sequences of random numbers with immense periods (ranging from around to ); those are its main advantages.
As with all pseudorandom number generators, the resulting sequences are functions of the supplied seed values.
An MWC generator is a special form of Lehmer random number generator which allows efficient implementation of a prime modulus much larger than the machine word size.
Normal Lehmer generator implementations choose a modulus close to the machine word size. An MWC generator instead maintains its state in base , so multiplying by is done implicitly by shifting one word. The base is typically chosen to equal the computer's word size, as this makes arithmetic modulo trivial. This may vary from for a microcontroller to . (This article uses for examples.)
The initial state ("seed") values are arbitrary, except that they must not be all zero, nor all at the maximum permitted values ( and ). (This is commonly done by choosing between 1 and .). The MWC sequence is then a sequence of pairs determined by
This is called a lag-1 MWC sequence. Sometimes an odd base is preferred, in which case can be used, which is almost as simple to implement. A lag- sequence is a generalization of the lag-1 sequence allowing longer periods. The lag- MWC sequence is then a sequence of pairs (for ) determined by
and the MWC generator output is the sequence of 's,
In this case, the initial state ("seed") values must not be all zero nor and .
Hub AI
Multiply-with-carry pseudorandom number generator AI simulator
(@Multiply-with-carry pseudorandom number generator_simulator)
Multiply-with-carry pseudorandom number generator
In computer science, multiply-with-carry (MWC) is a method invented by George Marsaglia for generating sequences of random integers based on an initial set from two to many thousands of randomly chosen seed values. It involves simple computational integer-arithmetic, and leads to high-speed generation of sequences of random numbers with immense periods (ranging from around to ); those are its main advantages.
As with all pseudorandom number generators, the resulting sequences are functions of the supplied seed values.
An MWC generator is a special form of Lehmer random number generator which allows efficient implementation of a prime modulus much larger than the machine word size.
Normal Lehmer generator implementations choose a modulus close to the machine word size. An MWC generator instead maintains its state in base , so multiplying by is done implicitly by shifting one word. The base is typically chosen to equal the computer's word size, as this makes arithmetic modulo trivial. This may vary from for a microcontroller to . (This article uses for examples.)
The initial state ("seed") values are arbitrary, except that they must not be all zero, nor all at the maximum permitted values ( and ). (This is commonly done by choosing between 1 and .). The MWC sequence is then a sequence of pairs determined by
This is called a lag-1 MWC sequence. Sometimes an odd base is preferred, in which case can be used, which is almost as simple to implement. A lag- sequence is a generalization of the lag-1 sequence allowing longer periods. The lag- MWC sequence is then a sequence of pairs (for ) determined by
and the MWC generator output is the sequence of 's,
In this case, the initial state ("seed") values must not be all zero nor and .