Random number generator (included): Difference between revisions

Content deleted Content added
Toucan (talk | contribs)
R random numbers
Added a section describing the random number generator available in Actionscript.
Line 9: Line 9:


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.
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}}==
In both ActionScript 2 and 3, the type of pseudorandom number generator is implementation-defined. This number generator is accessed through the Math.random() function, which returns a double greater than or equal to 0 and less than 1.[http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/Math.html#random%28%29][http://flash-reference.icod.de/Math.html#random%28%29] In Actionscript 2, the global random() function returns an integer greater than or equal to 0 and less than the given argument, but it is deprecated and not recommended.[http://flash-reference.icod.de/global_functions.html#random()]]


=={{header|C}}==
=={{header|C}}==