Random number generator (included): Difference between revisions

Content added Content deleted
Line 63: Line 63:
=={{header|Factor}}==
=={{header|Factor}}==
The default RNG used when the <code>random</code> vocabulary is used, is the [[wp:Mersenne twister|Mersenne twister]] algorithm [http://docs.factorcode.org/content/article-random.html]. But there are other RNGs available, including [[wp:SFMT|SFMT]], the system RNG ([[wp:/dev/random|/dev/random]] on Unix) and [[wp:Blum Blum Shub|Blum Blum Shub]]. It's also very easy to implement your own RNG and integrate it into the system. [http://docs.factorcode.org/content/article-random-protocol.html]
The default RNG used when the <code>random</code> vocabulary is used, is the [[wp:Mersenne twister|Mersenne twister]] algorithm [http://docs.factorcode.org/content/article-random.html]. But there are other RNGs available, including [[wp:SFMT|SFMT]], the system RNG ([[wp:/dev/random|/dev/random]] on Unix) and [[wp:Blum Blum Shub|Blum Blum Shub]]. It's also very easy to implement your own RNG and integrate it into the system. [http://docs.factorcode.org/content/article-random-protocol.html]
=={{header|GAP}}==
GAP may uses two algorithms : MersenneTwister, or algorithm A in section 3.2.2 of TAOCP (which is the default). On may create several ''random sources'' in parallel, or a global one (based on the TAOCP algorithm).
<lang gap># Creating a random source
rs := RandomSource(IsMersenneTwister);
# Generate a random number between 1 and 10
Random(rs, 1, 10);
# Same with default random source
Random(1, 10);</lang gap>
One can get random elements from many objects, including lists
<lang gap>
Random([1, 10, 100]);
# Random permutation of 1..200
Random(SymmetricGroup(200));
# Random element of Z/23Z :
Random(Integers mod 23);</lang>


=={{header|Haskell}}==
=={{header|Haskell}}==