Random number generator (included): Difference between revisions

m
We don't need to know the pros and cons
(Add Modula-3)
m (We don't need to know the pros and cons)
Line 8:
The main types of pseudo-random number generator, ([[wp:PRNG|PRNG]]), that are in use are the [[linear congruential generator|Linear Congruential Generator]], ([[wp:Linear congruential generator|LCG]]), and the Generalized Feedback Shift Register, ([[wp:Generalised_feedback_shift_register#Non-binary_Galois_LFSR|GFSR]]), (of which the [[wp:Mersenne twister|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 [[wp:Cryptographic hash function|cryptographic hash function]] to maximize unpredictability of individual bits.
 
Note that LCGs nor GFSRs should be used for the most demanding applications (cryptography) without additional steps.
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 [[wp:Monte Carlo method|Monte Carlo simulation]] and [[wp:Cryptography|cryptography]]. By contrast, GFSRs (of which the Mersenne Twister is a 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.
 
=={{header|ActionScript}}==