- All Implemented Interfaces:
RandomGenerator,RandomGenerator.StreamableGenerator
- Direct Known Subclasses:
EnhancedJumpableGenerator,EnhancedSplittableGenerator
An EnhancedStreamableGenerator is used to wrap an object of any
class that implements RandomGenerator.StreamableGenerator for the purpose
of adding all of the functionality of the RandomIndexer
and RandomVariates. See the superclass EnhancedRandomGenerator
for documentation of the enhanced functionality that is added to the
wrapped object.
The methods of the RandomGenerator.StreamableGenerator interface,
such as rngs(), 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 StreamableGenerator. However, additionally
this class provides a counterpart, such as erngs(), for each of these
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
ConstructorsConstructorDescriptionConstructs the EnhancedStreamableGenerator to wrap an instance of a default StreamableGenerator.EnhancedStreamableGenerator(long seed) Constructs the EnhancedStreamableGenerator to wrap an instance of a random number generator initialized with a specified seed to enable replicating the same sequence of random numbers during subsequent runs.EnhancedStreamableGenerator(String algorithmName) Constructs the EnhancedStreamableGenerator to wrap an instance of any random number generator supported by your version of Java as specified by its name, as documented via theRandomGenerator.StreamableGenerator.of(java.lang.String)method.Constructs an EnhancedStreamableGenerator to wrap and enhance a givenRandomGenerator.StreamableGenerator. -
Method Summary
Modifier and TypeMethodDescriptionfinal 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.static EnhancedStreamableGeneratorGets an EnhancedStreamableGenerator wrapping an instance of any random number generator supported by your version of Java as specified by its name, as documented via theRandomGenerator.StreamableGenerator.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, 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, nextIntTriple, nextIntTriple, nextLong, nextLong, nextLong, nextWindowedIntPair, nextWindowedIntTriple, nextWindowedIntTriple, sample, sample, sampleInsertion, samplePool, sampleReservoirMethods 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
-
EnhancedStreamableGenerator
public EnhancedStreamableGenerator()Constructs the EnhancedStreamableGenerator to wrap an instance of a default StreamableGenerator. The library's current default is to wrap an instance ofSplittableRandom, chosen due to Java's designation of that class as a legacy random number generator, and likely longterm existence. However, the rho-mu library makes no guarantee that this choice will remain the default. -
EnhancedStreamableGenerator
public EnhancedStreamableGenerator(long seed) Constructs the EnhancedStreamableGenerator to wrap an instance of a random number generator initialized with a specified seed to enable replicating the same sequence of random numbers during subsequent runs.- Parameters:
seed- The seed for the random number generator.
-
EnhancedStreamableGenerator
Constructs an EnhancedStreamableGenerator to wrap and enhance a givenRandomGenerator.StreamableGenerator.- Parameters:
generator- the RandomGenerator.StreamableGenerator to wrap and enhance.
-
EnhancedStreamableGenerator
Constructs the EnhancedStreamableGenerator to wrap an instance of any random number generator supported by your version of Java as specified by its name, as documented via theRandomGenerator.StreamableGenerator.of(java.lang.String)method.- Parameters:
algorithmName- The name of the random number generator as documented by theRandomGenerator.StreamableGenerator.of(java.lang.String)method.- Throws:
NullPointerException- if algorithmName is null.IllegalArgumentException- if algorithmName is not found.
-
-
Method Details
-
of
Gets an EnhancedStreamableGenerator wrapping an instance of any random number generator supported by your version of Java as specified by its name, as documented via theRandomGenerator.StreamableGenerator.of(java.lang.String)method.- Parameters:
algorithmName- The name of the random number generator as documented by theRandomGenerator.StreamableGenerator.of(java.lang.String)method.- Returns:
- an EnhancedStreamableGenerator wrapping an instance of your chosen random number generator.
- Throws:
NullPointerException- if algorithmName is null.IllegalArgumentException- if algorithmName is not found.
-
erngs
Gets an effectively unlimited stream of
EnhancedRandomGeneratorobjects, each wrapping an object of the same random number generator algorithm as this one.The behavior of this method is identical to that of
rngs(), but may be more convenient to use due to explicit return type of a stream of EnhancedRandomGenerator objects.- Returns:
- a stream of EnhancedRandomGenerator objects
-
erngs
Gets a stream of
EnhancedRandomGeneratorobjects, each wrapping an object of the same random number generator algorithm as this one.The behavior of this method is identical to that of
rngs(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
-
rngs
Gets an effectively unlimited stream of
EnhancedRandomGeneratorobjects, 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 theerngs()method, whose behavior is identical aside from the return type.- Specified by:
rngsin interfaceRandomGenerator.StreamableGenerator- Returns:
- a stream of EnhancedRandomGenerator objects
-
rngs
Gets a stream of
EnhancedRandomGeneratorobjects, 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 theerngs(long)method, whose behavior is identical aside from the return type.- Specified by:
rngsin interfaceRandomGenerator.StreamableGenerator- Parameters:
streamSize- the number of EnhancedRandomGenerator objects in the stream- Returns:
- a stream of EnhancedRandomGenerator objects
-