Package smile.math.random
Class MersenneTwister
- java.lang.Object
-
- smile.math.random.MersenneTwister
-
- All Implemented Interfaces:
RandomNumberGenerator
public class MersenneTwister extends java.lang.Object implements RandomNumberGenerator
-
-
Constructor Summary
Constructors Constructor Description MersenneTwister()
Constructor.MersenneTwister(int seed)
Constructor.MersenneTwister(long seed)
Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
next(int numbits)
Returns up to 32 random bits.double
nextDouble()
Returns the next pseudorandom, uniformly distributed double value between 0.0 and 1.0 from this random number generator's sequence.void
nextDoubles(double[] d)
Returns a vector of pseudorandom, uniformly distributed double values between 0.0 and 1.0 from this random number generator's sequence.int
nextInt()
Returns the next pseudorandom, uniformly distributed int value from this random number generator's sequence.int
nextInt(int n)
Returns a pseudorandom, uniformly distributed int value between 0 (inclusive) and the specified value (exclusive), drawn from this random number generator's sequence.long
nextLong()
Returns the next pseudorandom, uniformly distributed long value from this random number generator's sequence.void
setSeed(int seed)
void
setSeed(long seed)
Initialize the random generator with a seed.
-
-
-
Method Detail
-
setSeed
public void setSeed(long seed)
Description copied from interface:RandomNumberGenerator
Initialize the random generator with a seed.- Specified by:
setSeed
in interfaceRandomNumberGenerator
-
setSeed
public void setSeed(int seed)
-
next
public int next(int numbits)
Description copied from interface:RandomNumberGenerator
Returns up to 32 random bits.- Specified by:
next
in interfaceRandomNumberGenerator
-
nextDouble
public double nextDouble()
Description copied from interface:RandomNumberGenerator
Returns the next pseudorandom, uniformly distributed double value between 0.0 and 1.0 from this random number generator's sequence.- Specified by:
nextDouble
in interfaceRandomNumberGenerator
-
nextDoubles
public void nextDoubles(double[] d)
Description copied from interface:RandomNumberGenerator
Returns a vector of pseudorandom, uniformly distributed double values between 0.0 and 1.0 from this random number generator's sequence.- Specified by:
nextDoubles
in interfaceRandomNumberGenerator
-
nextInt
public int nextInt()
Description copied from interface:RandomNumberGenerator
Returns the next pseudorandom, uniformly distributed int value from this random number generator's sequence.- Specified by:
nextInt
in interfaceRandomNumberGenerator
-
nextInt
public int nextInt(int n)
Description copied from interface:RandomNumberGenerator
Returns a pseudorandom, uniformly distributed int value between 0 (inclusive) and the specified value (exclusive), drawn from this random number generator's sequence.- Specified by:
nextInt
in interfaceRandomNumberGenerator
-
nextLong
public long nextLong()
Description copied from interface:RandomNumberGenerator
Returns the next pseudorandom, uniformly distributed long value from this random number generator's sequence.- Specified by:
nextLong
in interfaceRandomNumberGenerator
-
-