Class EnhancedArbitrarilyJumpableGenerator
- All Implemented Interfaces:
RandomGenerator
,RandomGenerator.ArbitrarilyJumpableGenerator
,RandomGenerator.JumpableGenerator
,RandomGenerator.LeapableGenerator
,RandomGenerator.StreamableGenerator
RandomGenerator.ArbitrarilyJumpableGenerator
for the purpose of adding all of the
functionality of the RandomIndexer
, RandomSampler
, and RandomVariates
.
See the superclass EnhancedRandomGenerator
for documentation of the enhanced
functionality that is added to the wrapped object.
The methods of the RandomGenerator.ArbitrarilyJumpableGenerator
interface, such as
jumps(double)
, that return streams of RandomGenerator.ArbitrarilyJumpableGenerator are
implemented to return streams of EnhancedArbitrarilyJumpableGenerator objects that wrap the
RandomGenerator.ArbitrarilyJumpableGenerator objects in the streams returned by the enclosed
RandomGenerator.ArbitrarilyJumpableGenerator. However, additionally this class provides a
counterpart, such as ejumps(double)
, for each of these methods whose return type is
explicitly a stream of EnhancedArbitrarilyJumpableGenerator objects to simplify usage without the
need to cast the objects of the stream in order to utilize the enhancements.
-
Nested Class Summary
Nested classes/interfaces inherited from interface java.util.random.RandomGenerator
RandomGenerator.ArbitrarilyJumpableGenerator, RandomGenerator.JumpableGenerator, RandomGenerator.LeapableGenerator, RandomGenerator.SplittableGenerator, RandomGenerator.StreamableGenerator
-
Constructor Summary
ConstructorDescriptionEnhancedArbitrarilyJumpableGenerator
(String algorithmName) Constructs the EnhancedArbitrarilyJumpableGenerator to wrap an instance of any random number generator supported by your version of Java as specified by its name, as documented via theRandomGenerator.ArbitrarilyJumpableGenerator.of(java.lang.String)
method.Constructs an EnhancedArbitrarilyJumpableGenerator to wrap and enhance a givenRandomGenerator.ArbitrarilyJumpableGenerator
. -
Method Summary
Modifier and TypeMethodDescriptioncopy()
Creates and returns a new EnhancedArbitrarilyJumpableGenerator whose internal state is an exact copy of this one.copyAndJump
(double distance) Creates a copy of this EnhancedArbitrarilyJumpableGenerator, jumps this EnhancedArbitrarilyJumpableGenerator forward, and then returns the copy.ejumps
(double distance) Gets an effectively unlimited stream ofEnhancedArbitrarilyJumpableGenerator
objects, each wrapping an object of the same random number generator algorithm as this one.ejumps
(long streamSize, double distance) Gets a stream ofEnhancedArbitrarilyJumpableGenerator
objects, each wrapping an object of the same random number generator algorithm as this one.final void
jump
(double distance) Changes the state of this EnhancedArbitrarilyJumpableGenerator to jump a fixed distance ahead in its state cycle.final void
jumpPowerOfTwo
(int logDistance) Changes the state of this EnhancedArbitrarilyJumpableGenerator to jump a distance of 2logDistance ahead in its state cycle.jumps
(double distance) Gets an effectively unlimited stream ofEnhancedArbitrarilyJumpableGenerator
objects, each wrapping an object of the same random number generator algorithm as this one.jumps
(long streamSize, double distance) Gets a stream ofEnhancedArbitrarilyJumpableGenerator
objects, each wrapping an object of the same random number generator algorithm as this one.Gets an EnhancedArbitrarilyJumpableGenerator wrapping an instance of any random number generator supported by your version of Java as specified by its name, as documented via theRandomGenerator.ArbitrarilyJumpableGenerator.of(java.lang.String)
method.Methods inherited from class org.cicirello.math.rand.EnhancedLeapableGenerator
copyAndLeap, eleaps, eleaps, leap, leapDistance, leaps, leaps
Methods inherited from class org.cicirello.math.rand.EnhancedJumpableGenerator
copyAndJump, ejumps, ejumps, erngs, erngs, jump, jumpDistance, jumps, jumps, rngs, rngs
Methods inherited from class org.cicirello.math.rand.EnhancedRandomGenerator
arrayMask, arrayMask, arrayMask, biasedInts, biasedInts, binomials, binomials, cauchys, cauchys, doubles, doubles, doubles, doubles, exponentials, exponentials, gaussians, gaussians, gaussians, gaussians, getDefault, ints, ints, ints, ints, isDeprecated, longs, longs, longs, longs, nextBiasedInt, nextBiasedInt, nextBinomial, nextBoolean, nextBytes, nextCauchy, nextCauchy, nextDouble, nextDouble, nextDouble, nextExponential, nextFloat, nextFloat, nextFloat, nextGaussian, nextGaussian, nextGaussian, nextInt, nextInt, nextInt, nextIntPair, nextIntPair, nextIntTriple, nextIntTriple, nextLong, nextLong, nextLong, nextSortedIntPair, nextSortedIntPair, nextSortedIntTriple, nextSortedIntTriple, nextSortedWindowedIntPair, nextSortedWindowedIntPair, nextSortedWindowedIntTriple, nextSortedWindowedIntTriple, nextWindowedIntPair, nextWindowedIntPair, nextWindowedIntTriple, nextWindowedIntTriple, pairs, pairs, sample, sample, sampleInsertion, samplePool, sampleReservoir, shuffle, shuffle, shuffle, shuffle, shuffle, shuffle, shuffle, shuffle, shuffle, shuffle, shuffle, shuffle, shuffle, shuffle, shuffle, shuffle, shuffle, shuffle, sortedPairs, sortedPairs, sortedTriples, sortedTriples, sortedWindowedPairs, sortedWindowedPairs, sortedWindowedTriples, sortedWindowedTriples, triples, triples, windowedPairs, windowedPairs, windowedTriples, windowedTriples
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.util.random.RandomGenerator
doubles, doubles, doubles, doubles, ints, ints, ints, ints, isDeprecated, longs, longs, longs, longs, nextBoolean, nextBytes, nextDouble, nextDouble, nextDouble, nextExponential, nextFloat, nextFloat, nextFloat, nextGaussian, nextGaussian, nextInt, nextInt, nextInt, nextLong, nextLong, nextLong
Methods inherited from interface java.util.random.RandomGenerator.ArbitrarilyJumpableGenerator
jump, leap
Methods inherited from interface java.util.random.RandomGenerator.JumpableGenerator
copyAndJump, jumpDistance, jumps, jumps, rngs, rngs
Methods inherited from interface java.util.random.RandomGenerator.LeapableGenerator
copyAndLeap, leapDistance, leaps, leaps
-
Constructor Details
-
EnhancedArbitrarilyJumpableGenerator
Constructs an EnhancedArbitrarilyJumpableGenerator to wrap and enhance a givenRandomGenerator.ArbitrarilyJumpableGenerator
.- Parameters:
generator
- the RandomGenerator.ArbitrarilyJumpableGenerator to wrap and enhance.
-
EnhancedArbitrarilyJumpableGenerator
Constructs the EnhancedArbitrarilyJumpableGenerator to wrap an instance of any random number generator supported by your version of Java as specified by its name, as documented via theRandomGenerator.ArbitrarilyJumpableGenerator.of(java.lang.String)
method.- Parameters:
algorithmName
- The name of the random number generator as documented by theRandomGenerator.ArbitrarilyJumpableGenerator.of(java.lang.String)
method.- Throws:
NullPointerException
- if algorithmName is null.IllegalArgumentException
- if algorithmName is not found.
-
-
Method Details
-
of
Gets an EnhancedArbitrarilyJumpableGenerator wrapping an instance of any random number generator supported by your version of Java as specified by its name, as documented via theRandomGenerator.ArbitrarilyJumpableGenerator.of(java.lang.String)
method.- Parameters:
algorithmName
- The name of the random number generator as documented by theRandomGenerator.ArbitrarilyJumpableGenerator.of(java.lang.String)
method.- Returns:
- an EnhancedArbitrarilyJumpableGenerator wrapping an instance of your chosen random number generator.
- Throws:
NullPointerException
- if algorithmName is null.IllegalArgumentException
- if algorithmName is not found.
-
copy
Creates and returns a new EnhancedArbitrarilyJumpableGenerator whose internal state is an exact copy of this one. Thus, if subjected to the same series of actions, this EnhancedArbitrarilyJumpableGenerator and its copy should behave identically.- Specified by:
copy
in interfaceRandomGenerator.ArbitrarilyJumpableGenerator
- Specified by:
copy
in interfaceRandomGenerator.JumpableGenerator
- Specified by:
copy
in interfaceRandomGenerator.LeapableGenerator
- Overrides:
copy
in classEnhancedLeapableGenerator
- Returns:
- a new EnhancedArbitrarilyJumpableGenerator with internal state identical to this one.
-
copyAndJump
Creates a copy of this EnhancedArbitrarilyJumpableGenerator, jumps this EnhancedArbitrarilyJumpableGenerator forward, and then returns the copy.- Specified by:
copyAndJump
in interfaceRandomGenerator.ArbitrarilyJumpableGenerator
- Parameters:
distance
- the distance to jump ahead in the state cycle- Returns:
- a copy of this EnhancedArbitrarilyJumpableGenerator before the jump occurred.
-
jump
public final void jump(double distance) Changes the state of this EnhancedArbitrarilyJumpableGenerator to jump a fixed distance ahead in its state cycle.- Specified by:
jump
in interfaceRandomGenerator.ArbitrarilyJumpableGenerator
- Parameters:
distance
- the distance to jump ahead in the state cycle
-
jumpPowerOfTwo
public final void jumpPowerOfTwo(int logDistance) Changes the state of this EnhancedArbitrarilyJumpableGenerator to jump a distance of 2logDistance ahead in its state cycle.- Specified by:
jumpPowerOfTwo
in interfaceRandomGenerator.ArbitrarilyJumpableGenerator
- Parameters:
logDistance
- the base-2 logarithm of the distance to jump ahead in the state cycle
-
ejumps
Gets an effectively unlimited stream ofEnhancedArbitrarilyJumpableGenerator
objects, each wrapping an object of the same random number generator algorithm as this one.The implementation of this method from the
RandomGenerator.ArbitrarilyJumpableGenerator
interface returns a stream ofEnhancedArbitrarilyJumpableGenerator
objects, and is thus safe to cast the objects of the stream toEnhancedArbitrarilyJumpableGenerator
. However, you may find it more convenient to instead utilize theejumps(double)
method, whose behavior is identical aside from the return type.- Parameters:
distance
- the distance to jump ahead in the state cycle- Returns:
- a stream of EnhancedArbitrarilyJumpableGenerator objects
-
ejumps
Gets a stream ofEnhancedArbitrarilyJumpableGenerator
objects, each wrapping an object of the same random number generator algorithm as this one.The implementation of this method from the
RandomGenerator.ArbitrarilyJumpableGenerator
interface returns a stream ofEnhancedArbitrarilyJumpableGenerator
objects, and is thus safe to cast the objects of the stream toEnhancedArbitrarilyJumpableGenerator
. However, you may find it more convenient to instead utilize theejumps(long, double)
method, whose behavior is identical aside from the return type.- Parameters:
streamSize
- the number of EnhancedArbitrarilyJumpableGenerator objects in the streamdistance
- the distance to jump ahead in the state cycle- Returns:
- a stream of EnhancedArbitrarilyJumpableGenerator objects
-
jumps
Gets an effectively unlimited stream ofEnhancedArbitrarilyJumpableGenerator
objects, each wrapping an object of the same random number generator algorithm as this one.The implementation of this method from the
RandomGenerator.ArbitrarilyJumpableGenerator
interface returns a stream ofEnhancedArbitrarilyJumpableGenerator
objects, and is thus safe to cast the objects of the stream toEnhancedArbitrarilyJumpableGenerator
. However, you may find it more convenient to instead utilize theejumps(double)
method, whose behavior is identical aside from the return type.- Specified by:
jumps
in interfaceRandomGenerator.ArbitrarilyJumpableGenerator
- Parameters:
distance
- the distance to jump ahead in the state cycle- Returns:
- a stream of EnhancedArbitrarilyJumpableGenerator objects
-
jumps
public final Stream<RandomGenerator.ArbitrarilyJumpableGenerator> jumps(long streamSize, double distance) Gets a stream ofEnhancedArbitrarilyJumpableGenerator
objects, each wrapping an object of the same random number generator algorithm as this one.The implementation of this method from the
RandomGenerator.ArbitrarilyJumpableGenerator
interface returns a stream ofEnhancedArbitrarilyJumpableGenerator
objects, and is thus safe to cast the objects of the stream toEnhancedArbitrarilyJumpableGenerator
. However, you may find it more convenient to instead utilize theejumps(long, double)
method, whose behavior is identical aside from the return type.- Specified by:
jumps
in interfaceRandomGenerator.ArbitrarilyJumpableGenerator
- Parameters:
streamSize
- the number of EnhancedArbitrarilyJumpableGenerator objects in the streamdistance
- the distance to jump ahead in the state cycle- Returns:
- a stream of EnhancedArbitrarilyJumpableGenerator objects
-