Class LcgFactory
LCG is a commonly used random number generator in the past.
Recurrence relation sequences : X(n+1) = (X(n) * Mul + Inc) mod Mod
- Mul : Multiplier
- Inc : Increment
- Mod : Modulus
Provides a random number generator compatible with the following LCGs.
- RANDU : IBM Scientific Subroutine Library for IBM System/360
- MINSTD0 : C++11's minstd_rand0
- MINSTD : C++11's minstd_rand
- GLIBC : glibc rand()
- LRAND48 : glibc lrand48()
- MRAND48 : glibc mrand48()
mrand48() is compatible with Random
.
But seed of java.util.Random is scrambled. Try seedScrambler4M48(long)
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionstatic LcgRndInt31
Create glibc rand() compatible random number generator.static LcgRndInt31
Create lrand48() compatible random number generator.static LcgRndInt31
Create minstd_rand() compatible random number generator.static LcgRndInt31
Create minstd_rand0() compatible random number generator.static LcgRndInt32
Create mrand48() compatible random generator.static LcgRndInt31
Create RANDU compatible random number generator.static long
seedScrambler4M48
(long seedArg) Seed scrambler for mrand48().
-
Method Details
-
createRandu
Create RANDU compatible random number generator.RANDU was included in IBM Scientific Subroutine Library for IBM System/360
RANDU generates 31bit output without sign.
- Returns:
- random number generator
- See Also:
-
createMinStd0
Create minstd_rand0() compatible random number generator.minstd_rand0() is used in C++11.
minstd_rand() is better than minstd_rand0(),
minstd_rand0() generates 31bit output without sign.
- Returns:
- random number generator
- See Also:
-
createMinStd
Create minstd_rand() compatible random number generator.minstd_rand() is used in C++11.
minstd_rand() is better than minstd_rand0(),
minstd_rand() generates 31bit output without sign.
- Returns:
- random number generator
- See Also:
-
createGlibc
Create glibc rand() compatible random number generator.rand() is used in glibc library.
rand() generates 31bit output without sign.
- Returns:
- random number generator
-
createLrand48
Create lrand48() compatible random number generator.lrand48() is used in Un*x common C-library.
lrand48() generates 31bit output without sign. result(31bit) reflects seed[17:47]
- Returns:
- random number generator
-
createMrand48
Create mrand48() compatible random generator.mrand48() is used in Un*x common C-library.
mrand48() generates 32bit output.
- Returns:
- random number generator
-
seedScrambler4M48
public static long seedScrambler4M48(long seedArg) Seed scrambler for mrand48().Seed of
Random.setSeed(long)
will be converted to seed of mrand48().- Parameters:
seedArg
- seed ofRandom
- Returns:
- seed of mrand48()
- See Also:
-