- All Implemented Interfaces:
RandomGenerator,RandomGenerator.JumpableGenerator,RandomGenerator.LeapableGenerator,RandomGenerator.StreamableGenerator
- Direct Known Subclasses:
EnhancedArbitrarilyJumpableGenerator
RandomGenerator.LeapableGenerator 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.LeapableGenerator interface, such as leaps(), that return streams of RandomGenerator.JumpableGenerator are implemented to return
streams of EnhancedJumpableGenerator objects that wrap the RandomGenerator.JumpableGenerator
objects in the streams returned by the enclosed RandomGenerator.LeapableGenerator. However,
additionally this class provides a counterpart, such as eleaps(), for each of these
methods whose return type is explicitly a stream of EnhancedJumpableGenerator 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
ConstructorsConstructorDescriptionEnhancedLeapableGenerator(String algorithmName) Constructs the EnhancedLeapableGenerator to wrap an instance of any random number generator supported by your version of Java as specified by its name, as documented via theRandomGenerator.LeapableGenerator.of(java.lang.String)method.Constructs an EnhancedLeapableGenerator to wrap and enhance a givenRandomGenerator.LeapableGenerator. -
Method Summary
Modifier and TypeMethodDescriptioncopy()Creates and returns a new EnhancedLeapableGenerator whose internal state is an exact copy of this one.Creates a copy of this EnhancedLeapableGenerator, leaps this EnhancedLeapableGenerator forward, and then returns the copy.final Stream<EnhancedJumpableGenerator>eleaps()Gets an effectively unlimited stream ofEnhancedJumpableGeneratorobjects, each wrapping an object of the same random number generator algorithm as this one.final Stream<EnhancedJumpableGenerator>eleaps(long streamSize) Gets a stream ofEnhancedJumpableGeneratorobjects, each wrapping an object of the same random number generator algorithm as this one.final voidleap()Changes the state of this EnhancedLeapableGenerator to leap a large fixed distance, indicated by theleapDistance()method, in its state cycle.final doubleReturns the distance by which theleap()method will leap ahead in this EnhancedLeapableGenerator instance's state cycle.leaps()Gets an effectively unlimited stream ofEnhancedJumpableGeneratorobjects, each wrapping an object of the same random number generator algorithm as this one.leaps(long streamSize) Gets a stream ofEnhancedJumpableGeneratorobjects, each wrapping an object of the same random number generator algorithm as this one.static EnhancedLeapableGeneratorGets an EnhancedLeapableGenerator wrapping an instance of any random number generator supported by your version of Java as specified by its name, as documented via theRandomGenerator.LeapableGenerator.of(java.lang.String)method.Methods inherited from class org.cicirello.math.rand.EnhancedJumpableGenerator
copyAndJump, ejumps, ejumps, erngs, erngs, jump, jumpDistance, jumps, jumps, rngs, rngsMethods 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, windowedTriplesMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods 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, nextLongMethods inherited from interface java.util.random.RandomGenerator.JumpableGenerator
copyAndJump, jump, jumpDistance, jumps, jumps, rngs, rngs
-
Constructor Details
-
EnhancedLeapableGenerator
Constructs an EnhancedLeapableGenerator to wrap and enhance a givenRandomGenerator.LeapableGenerator.- Parameters:
generator- the RandomGenerator.LeapableGenerator to wrap and enhance.
-
EnhancedLeapableGenerator
Constructs the EnhancedLeapableGenerator to wrap an instance of any random number generator supported by your version of Java as specified by its name, as documented via theRandomGenerator.LeapableGenerator.of(java.lang.String)method.- Parameters:
algorithmName- The name of the random number generator as documented by theRandomGenerator.LeapableGenerator.of(java.lang.String)method.- Throws:
NullPointerException- if algorithmName is null.IllegalArgumentException- if algorithmName is not found.
-
-
Method Details
-
of
Gets an EnhancedLeapableGenerator wrapping an instance of any random number generator supported by your version of Java as specified by its name, as documented via theRandomGenerator.LeapableGenerator.of(java.lang.String)method.- Parameters:
algorithmName- The name of the random number generator as documented by theRandomGenerator.LeapableGenerator.of(java.lang.String)method.- Returns:
- an EnhancedLeapableGenerator 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 EnhancedLeapableGenerator whose internal state is an exact copy of this one. Thus, if subjected to the same series of actions, this EnhancedLeapableGenerator and its copy should behave identically.- Specified by:
copyin interfaceRandomGenerator.JumpableGenerator- Specified by:
copyin interfaceRandomGenerator.LeapableGenerator- Overrides:
copyin classEnhancedJumpableGenerator- Returns:
- a new EnhancedLeapableGenerator with internal state identical to this one.
-
copyAndLeap
Creates a copy of this EnhancedLeapableGenerator, leaps this EnhancedLeapableGenerator forward, and then returns the copy.- Specified by:
copyAndLeapin interfaceRandomGenerator.LeapableGenerator- Returns:
- a copy of this EnhancedLeapableGenerator before the leap occurred.
-
leap
public final void leap()Changes the state of this EnhancedLeapableGenerator to leap a large fixed distance, indicated by theleapDistance()method, in its state cycle.- Specified by:
leapin interfaceRandomGenerator.LeapableGenerator
-
leapDistance
public final double leapDistance()Returns the distance by which theleap()method will leap ahead in this EnhancedLeapableGenerator instance's state cycle.- Specified by:
leapDistancein interfaceRandomGenerator.LeapableGenerator- Returns:
- the leap distance
-
eleaps
Gets an effectively unlimited stream ofEnhancedJumpableGeneratorobjects, each wrapping an object of the same random number generator algorithm as this one. Although jumpable, the random number generators in the stream are not also leapable.The behavior of this method is identical to that of
leaps(), but may be more convenient to use due to explicit return type of a stream of EnhancedJumpableGenerator objects.- Returns:
- a stream of EnhancedJumpableGenerator objects
-
eleaps
Gets a stream ofEnhancedJumpableGeneratorobjects, each wrapping an object of the same random number generator algorithm as this one. Although jumpable, the random number generators in the stream are not also leapable.The behavior of this method is identical to that of
leaps(long), but may be more convenient to use due to explicit return type of a stream of EnhancedJumpableGenerator objects.- Parameters:
streamSize- the number of EnhancedJumpableGenerator objects in the stream- Returns:
- a stream of EnhancedJumpableGenerator objects
-
leaps
Gets an effectively unlimited stream ofEnhancedJumpableGeneratorobjects, each wrapping an object of the same random number generator algorithm as this one. Although jumpable, the random number generators in the stream are not also leapable.The implementation of this method from the
RandomGenerator.LeapableGeneratorinterface returns a stream ofEnhancedJumpableGeneratorobjects, and is thus safe to cast the objects of the stream toEnhancedJumpableGenerator. However, you may find it more convenient to instead utilize theeleaps()method, whose behavior is identical aside from the return type.- Specified by:
leapsin interfaceRandomGenerator.LeapableGenerator- Returns:
- a stream of EnhancedJumpableGenerator objects
-
leaps
Gets a stream ofEnhancedJumpableGeneratorobjects, each wrapping an object of the same random number generator algorithm as this one. Although jumpable, the random number generators in the stream are not also leapable.The implementation of this method from the
RandomGenerator.JumpableGeneratorinterface returns a stream ofEnhancedJumpableGeneratorobjects, and is thus safe to cast the objects of the stream toEnhancedJumpableGenerator. However, you may find it more convenient to instead utilize theeleaps(long)method, whose behavior is identical aside from the return type.- Specified by:
leapsin interfaceRandomGenerator.LeapableGenerator- Parameters:
streamSize- the number of EnhancedJumpableGenerator objects in the stream- Returns:
- a stream of EnhancedJumpableGenerator objects
-