Re: Need a good RNG and a LCG, both with a max period >= 31 bits
On Jun 11, 11:08 am, rahul <rahulsin...@gmail.com> wrote:
On Jun 11, 12:17 am, "Adem24" <ade...@nospammplease.org.invalid>
wrote:
I need a good and fast random number generator (RNG), and a
linear congruential generator (LCG), both with a max period
= 31 bits; the bigger the better.
Additional requirements:
- Must use [unsigned] integer-values only (32 or 64 bit), no floating po=
int.
- The RNG should have passed some statistical tests.
- The "RAND_MAX" of these generators should equal the period.
- The LCG should of course generate each number only once in a period.
- The period of the LCG should easily be changable programmatically
for at least any n of 2^n upto the max possible n.
- They must be written in C or C++.
Which RNG and LCG can you recommend which satisfy these requirements?
/dev/random is considered Cryptographically Secure
Pseduo-Random number generator. But I am not aware of its
period. And you don't have the source code for it. Its
implemented in kernel and you will have to manually browse
through the code to get the algorithm. It uses the noise from
the device drivers.
/dev/random is only available on some Unix systems, and it is
not (normally, at least) a pseudo-random generator, but rather
provides access to a truly random source. It can also be
painfully slow, since it must wait for sufficient entropy; it's
very useful for getting a random number to seed an RNG, but it's
probably too slow for any extended use.
The original posting is cross-posted to both comp.lang.c and
comp.lang.c++, so I don't know which language the original
poster uses---if it's C++, Boost has a large collection of
random number generators (which will be incorporated into the
next version of the standard).
--
James Kanze (GABI Software) email:james.kanze@gmail.com
Conseils en informatique orient=E9e objet/
Beratung in objektorientierter Datenverarbeitung
9 place S=E9mard, 78210 St.-Cyr-l'=C9cole, France, +33 (0)1 30 23 00 34