Class Well512a
java.lang.Object
org.apache.commons.math3.random.BitsStreamGenerator
org.apache.commons.math3.random.AbstractWell
org.apache.commons.math3.random.Well512a
- All Implemented Interfaces:
Serializable, RandomGenerator
This class implements the WELL512a pseudo-random number generator
from François Panneton, Pierre L'Ecuyer and Makoto Matsumoto.
This generator is described in a paper by François Panneton, Pierre L'Ecuyer and Makoto Matsumoto Improved Long-Period Generators Based on Linear Recurrences Modulo 2 ACM Transactions on Mathematical Software, 32, 1 (2006). The errata for the paper are in wellrng-errata.txt.
- Since:
- 2.2
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final intNumber of bits in the pool.private static final intFirst parameter of the algorithm.private static final intSecond parameter of the algorithm.private static final intThird parameter of the algorithm.private static final longSerializable version identifier. -
Constructor Summary
ConstructorsConstructorDescriptionWell512a()Creates a new random number generator.Well512a(int seed) Creates a new random number generator using a single int seed.Well512a(int[] seed) Creates a new random number generator using an int array seed.Well512a(long seed) Creates a new random number generator using a single long seed. -
Method Summary
Modifier and TypeMethodDescriptionprotected intnext(int bits) Generate next pseudorandom number.Methods inherited from class AbstractWell
setSeed, setSeed, setSeedMethods inherited from class BitsStreamGenerator
clear, nextBoolean, nextBytes, nextBytes, nextDouble, nextFloat, nextGaussian, nextInt, nextInt, nextLong, nextLong
-
Field Details
-
serialVersionUID
private static final long serialVersionUIDSerializable version identifier.- See Also:
-
K
private static final int KNumber of bits in the pool.- See Also:
-
M1
private static final int M1First parameter of the algorithm.- See Also:
-
M2
private static final int M2Second parameter of the algorithm.- See Also:
-
M3
private static final int M3Third parameter of the algorithm.- See Also:
-
-
Constructor Details
-
Well512a
public Well512a()Creates a new random number generator.The instance is initialized using the current time as the seed.
-
Well512a
public Well512a(int seed) Creates a new random number generator using a single int seed.- Parameters:
seed- the initial seed (32 bits integer)
-
Well512a
public Well512a(int[] seed) Creates a new random number generator using an int array seed.- Parameters:
seed- the initial seed (32 bits integers array), if null the seed of the generator will be related to the current time
-
Well512a
public Well512a(long seed) Creates a new random number generator using a single long seed.- Parameters:
seed- the initial seed (64 bits integer)
-
-
Method Details
-
next
protected int next(int bits) Generate next pseudorandom number.This method is the core generation algorithm. It is used by all the public generation methods for the various primitive types
BitsStreamGenerator.nextBoolean(),BitsStreamGenerator.nextBytes(byte[]),BitsStreamGenerator.nextDouble(),BitsStreamGenerator.nextFloat(),BitsStreamGenerator.nextGaussian(),BitsStreamGenerator.nextInt(),BitsStreamGenerator.next(int)andBitsStreamGenerator.nextLong().- Specified by:
nextin classAbstractWell- Parameters:
bits- number of random bits to produce- Returns:
- random bits generated
-