Talk:Random number generator (included)

From Rosetta Code
Revision as of 16:17, 24 January 2010 by rosettacode>Dkf (→‎Main types of PRNG: new section)

Remove draft status?

The entries so far are as I had hoped. --Paddy3118 15:03, 24 January 2010 (UTC)

Main types of PRNG

This might be text sometime to transfer to the main task page.

The main types of PRNG that are in use are the Linear Congruential Generator and the Generalized Feedback Shift Register (of which the mersenne twister generator is a subclass). The last main type is where the output of one of the previous ones (typically a mersenne twister) is fed through a cryptographic hash function to maximize unpredictability of individual bits.
LCGs have the advantage of not requiring much state and being very fast to calculate, but produce random numbers with spectral problems. This makes them unsuitable for both Monte Carlo simulation and cryptography. By contrast, GFSRs (of which the Mersenne Twister is is particularly high quality version) require a lot more internal state and are considerably more expensive to compute and initialize (so much so that it is normal to use a LCG or simpler GFSR to drive the initialization); GFSRs tend to have much higher quality spectral properties than LCGs, and are suitable for use in Monte Carlo simulation. Neither LCGs nor GFSRs should be used for the most demanding applications (cryptography) without additional steps.

Probably needs more work. Feel free to massage! –Donal Fellows 16:17, 24 January 2010 (UTC)