Class CellularAutomatonRNG
java.lang.Object
java.util.Random
org.uncommons.maths.random.CellularAutomatonRNG
- All Implemented Interfaces:
Serializable, RandomGenerator, RepeatableRNG
Java port of the cellular automaton pseudorandom number generator developed by Tony Pasqualoni.
NOTE: Instances of this class do not use the seeding mechanism inherited
from Random. Calls to the Random.setSeed(long) method will have no
effect. Instead the seed must be set by a constructor.
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface RandomGenerator
RandomGenerator.ArbitrarilyJumpableGenerator, RandomGenerator.JumpableGenerator, RandomGenerator.LeapableGenerator, RandomGenerator.SplittableGenerator, RandomGenerator.StreamableGenerator -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final intprivate final int[]private intprivate final ReentrantLockprivate static final int[]private final byte[]private static final int -
Constructor Summary
ConstructorsConstructorDescriptionCreates a new RNG and seeds it using the default seeding strategy.CellularAutomatonRNG(byte[] seed) Creates an RNG and seeds it with the specified seed data.CellularAutomatonRNG(SeedGenerator seedGenerator) Seed the RNG using the provided seed generation strategy. -
Method Summary
Modifier and TypeMethodDescriptionprivate static intconvertCellsToInt(int[] cells, int offset) byte[]getSeed()intnext(int bits) Methods inherited from class Random
doubles, doubles, doubles, doubles, from, ints, ints, ints, ints, longs, longs, longs, longs, nextBoolean, nextBytes, nextDouble, nextFloat, nextGaussian, nextInt, nextInt, nextLong, setSeedMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface RandomGenerator
equiDoubles, isDeprecated, nextDouble, nextDouble, nextExponential, nextFloat, nextFloat, nextGaussian, nextInt, nextLong, nextLong
-
Field Details
-
SEED_SIZE_BYTES
private static final int SEED_SIZE_BYTES- See Also:
-
AUTOMATON_LENGTH
private static final int AUTOMATON_LENGTH- See Also:
-
RNG_RULE
private static final int[] RNG_RULE -
seed
private final byte[] seed -
cells
private final int[] cells -
lock
-
currentCellIndex
private int currentCellIndex
-
-
Constructor Details
-
CellularAutomatonRNG
public CellularAutomatonRNG()Creates a new RNG and seeds it using the default seeding strategy. -
CellularAutomatonRNG
Seed the RNG using the provided seed generation strategy.- Parameters:
seedGenerator- The seed generation strategy that will provide the seed value for this RNG.- Throws:
SeedException- If there is a problem generating a seed.
-
CellularAutomatonRNG
public CellularAutomatonRNG(byte[] seed) Creates an RNG and seeds it with the specified seed data.- Parameters:
seed- The seed data used to initialise the RNG.
-
-
Method Details
-
next
-
getSeed
public byte[] getSeed()- Specified by:
getSeedin interfaceRepeatableRNG- Returns:
- The seed data used to initialise this pseudo-random number generator.
-
convertCellsToInt
private static int convertCellsToInt(int[] cells, int offset)
-