- All Implemented Interfaces:
RandomGenerator,RandomGenerator.JumpableGenerator,RandomGenerator.StreamableGenerator
- Direct Known Subclasses:
EnhancedLeapableGenerator
RandomGenerator.JumpableGenerator 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.JumpableGenerator interface, such as jumps(), that return streams of RandomGenerator are implemented to return streams of
EnhancedRandomGenerator objects that wrap the RandomGenerator objects in the streams returned by
the enclosed RandomGenerator.JumpableGenerator. However, additionally this class provides a
counterpart, such as ejumps(), for each of these methods whose return type is explicitly a
stream of EnhancedRandomGenerator 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
ConstructorsConstructorDescriptionEnhancedJumpableGenerator(String algorithmName) Constructs the EnhancedJumpableGenerator to wrap an instance of any random number generator supported by your version of Java as specified by its name, as documented via theRandomGenerator.JumpableGenerator.of(java.lang.String)method.Constructs an EnhancedJumpableGenerator to wrap and enhance a givenRandomGenerator.JumpableGenerator. -
Method Summary
Modifier and TypeMethodDescriptioncopy()Creates and returns a new EnhancedJumpableGenerator whose internal state is an exact copy of this one.Creates a copy of this EnhancedJumpableGenerator, jumps this EnhancedJumpableGenerator forward, and then returns the copy.final Stream<EnhancedRandomGenerator>ejumps()Gets an effectively unlimited stream ofEnhancedRandomGeneratorobjects, each wrapping an object of the same random number generator algorithm as this one.final Stream<EnhancedRandomGenerator>ejumps(long streamSize) Gets a stream ofEnhancedRandomGeneratorobjects, each wrapping an object of the same random number generator algorithm as this one.final Stream<EnhancedRandomGenerator>erngs()Gets an effectively unlimited stream ofEnhancedRandomGeneratorobjects, each wrapping an object of the same random number generator algorithm as this one.final Stream<EnhancedRandomGenerator>erngs(long streamSize) Gets a stream ofEnhancedRandomGeneratorobjects, each wrapping an object of the same random number generator algorithm as this one.final voidjump()Changes the state of this EnhancedJumpableGenerator to jump a large fixed distance, indicated by thejumpDistance()method, in its state cycle.final doubleReturns the distance by which thejump()method will jump ahead in this EnhancedJumpableGenerator instance's state cycle.final Stream<RandomGenerator>jumps()Gets an effectively unlimited stream ofEnhancedRandomGeneratorobjects, each wrapping an object of the same random number generator algorithm as this one.final Stream<RandomGenerator>jumps(long streamSize) Gets a stream ofEnhancedRandomGeneratorobjects, each wrapping an object of the same random number generator algorithm as this one.static EnhancedJumpableGeneratorGets an EnhancedJumpableGenerator wrapping an instance of any random number generator supported by your version of Java as specified by its name, as documented via theRandomGenerator.JumpableGenerator.of(java.lang.String)method.final Stream<RandomGenerator>rngs()Gets an effectively unlimited stream ofEnhancedRandomGeneratorobjects, each wrapping an object of the same random number generator algorithm as this one.final Stream<RandomGenerator>rngs(long streamSize) Gets a stream ofEnhancedRandomGeneratorobjects, each wrapping an object of the same random number generator algorithm as this one.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, 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, nextLong
-
Constructor Details
-
EnhancedJumpableGenerator
Constructs an EnhancedJumpableGenerator to wrap and enhance a givenRandomGenerator.JumpableGenerator.- Parameters:
generator- the RandomGenerator.JumpableGenerator to wrap and enhance.
-
EnhancedJumpableGenerator
Constructs the EnhancedJumpableGenerator to wrap an instance of any random number generator supported by your version of Java as specified by its name, as documented via theRandomGenerator.JumpableGenerator.of(java.lang.String)method.- Parameters:
algorithmName- The name of the random number generator as documented by theRandomGenerator.JumpableGenerator.of(java.lang.String)method.- Throws:
NullPointerException- if algorithmName is null.IllegalArgumentException- if algorithmName is not found.
-
-
Method Details
-
of
Gets an EnhancedJumpableGenerator wrapping an instance of any random number generator supported by your version of Java as specified by its name, as documented via theRandomGenerator.JumpableGenerator.of(java.lang.String)method.- Parameters:
algorithmName- The name of the random number generator as documented by theRandomGenerator.JumpableGenerator.of(java.lang.String)method.- Returns:
- an EnhancedJumpableGenerator 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 EnhancedJumpableGenerator whose internal state is an exact copy of this one. Thus, if subjected to the same series of actions, this EnhancedJumpableGenerator and its copy should behave identically.- Specified by:
copyin interfaceRandomGenerator.JumpableGenerator- Returns:
- a new EnhancedJumpableGenerator with internal state identical to this one.
-
copyAndJump
Creates a copy of this EnhancedJumpableGenerator, jumps this EnhancedJumpableGenerator forward, and then returns the copy.- Specified by:
copyAndJumpin interfaceRandomGenerator.JumpableGenerator- Returns:
- a copy of this EnhancedJumpableGenerator before the jump occurred.
-
jump
public final void jump()Changes the state of this EnhancedJumpableGenerator to jump a large fixed distance, indicated by thejumpDistance()method, in its state cycle.- Specified by:
jumpin interfaceRandomGenerator.JumpableGenerator
-
jumpDistance
public final double jumpDistance()Returns the distance by which thejump()method will jump ahead in this EnhancedJumpableGenerator instance's state cycle.- Specified by:
jumpDistancein interfaceRandomGenerator.JumpableGenerator- Returns:
- the jump distance
-
ejumps
Gets an effectively unlimited stream ofEnhancedRandomGeneratorobjects, each wrapping an object of the same random number generator algorithm as this one. The random number generators in the stream are not also jumpable.The behavior of this method is identical to that of
jumps(), but may be more convenient to use due to explicit return type of a stream of EnhancedRandomGenerator objects.- Returns:
- a stream of EnhancedRandomGenerator objects
-
ejumps
Gets a stream ofEnhancedRandomGeneratorobjects, each wrapping an object of the same random number generator algorithm as this one. The random number generators in the stream are not also jumpable.The behavior of this method is identical to that of
jumps(long), but may be more convenient to use due to explicit return type of a stream of EnhancedRandomGenerator objects.- Parameters:
streamSize- the number of EnhancedRandomGenerator objects in the stream- Returns:
- a stream of EnhancedRandomGenerator objects
-
jumps
Gets an effectively unlimited stream ofEnhancedRandomGeneratorobjects, each wrapping an object of the same random number generator algorithm as this one. The random number generators in the stream are not also jumpable.The implementation of this method from the
RandomGenerator.JumpableGeneratorinterface returns a stream ofEnhancedRandomGeneratorobjects, and is thus safe to cast the objects of the stream toEnhancedRandomGenerator. However, you may find it more convenient to instead utilize theejumps()method, whose behavior is identical aside from the return type.- Specified by:
jumpsin interfaceRandomGenerator.JumpableGenerator- Returns:
- a stream of EnhancedRandomGenerator objects
-
jumps
Gets a stream ofEnhancedRandomGeneratorobjects, each wrapping an object of the same random number generator algorithm as this one. The random number generators in the stream are not also jumpable.The implementation of this method from the
RandomGenerator.JumpableGeneratorinterface returns a stream ofEnhancedRandomGeneratorobjects, and is thus safe to cast the objects of the stream toEnhancedRandomGenerator. However, you may find it more convenient to instead utilize theejumps(long)method, whose behavior is identical aside from the return type.- Specified by:
jumpsin interfaceRandomGenerator.JumpableGenerator- Parameters:
streamSize- the number of EnhancedRandomGenerator objects in the stream- Returns:
- a stream of EnhancedRandomGenerator objects
-
erngs
Description copied from class:EnhancedStreamableGeneratorGets an effectively unlimited stream ofEnhancedRandomGeneratorobjects, each wrapping an object of the same random number generator algorithm as this one.The behavior of this method is identical to that of
EnhancedStreamableGenerator.rngs(), but may be more convenient to use due to explicit return type of a stream of EnhancedRandomGenerator objects.- Overrides:
erngsin classEnhancedStreamableGenerator- Returns:
- a stream of EnhancedRandomGenerator objects
-
erngs
Description copied from class:EnhancedStreamableGeneratorGets a stream ofEnhancedRandomGeneratorobjects, each wrapping an object of the same random number generator algorithm as this one.The behavior of this method is identical to that of
EnhancedStreamableGenerator.rngs(long), but may be more convenient to use due to explicit return type of a stream of EnhancedRandomGenerator objects.- Overrides:
erngsin classEnhancedStreamableGenerator- Parameters:
streamSize- the number of EnhancedRandomGenerator objects in the stream- Returns:
- a stream of EnhancedRandomGenerator objects
-
rngs
Description copied from class:EnhancedStreamableGeneratorGets an effectively unlimited stream ofEnhancedRandomGeneratorobjects, each wrapping an object of the same random number generator algorithm as this one.The implementation of this method from the
RandomGenerator.StreamableGeneratorinterface returns a stream ofEnhancedRandomGeneratorobjects, and is thus safe to cast the objects of the stream toEnhancedRandomGenerator. However, you may find it more convenient to instead utilize theEnhancedStreamableGenerator.erngs()method, whose behavior is identical aside from the return type.- Specified by:
rngsin interfaceRandomGenerator.JumpableGenerator- Specified by:
rngsin interfaceRandomGenerator.StreamableGenerator- Overrides:
rngsin classEnhancedStreamableGenerator- Returns:
- a stream of EnhancedRandomGenerator objects
-
rngs
Description copied from class:EnhancedStreamableGeneratorGets a stream ofEnhancedRandomGeneratorobjects, each wrapping an object of the same random number generator algorithm as this one.The implementation of this method from the
RandomGenerator.StreamableGeneratorinterface returns a stream ofEnhancedRandomGeneratorobjects, and is thus safe to cast the objects of the stream toEnhancedRandomGenerator. However, you may find it more convenient to instead utilize theEnhancedStreamableGenerator.erngs(long)method, whose behavior is identical aside from the return type.- Specified by:
rngsin interfaceRandomGenerator.JumpableGenerator- Specified by:
rngsin interfaceRandomGenerator.StreamableGenerator- Overrides:
rngsin classEnhancedStreamableGenerator- Parameters:
streamSize- the number of EnhancedRandomGenerator objects in the stream- Returns:
- a stream of EnhancedRandomGenerator objects
-