- All Implemented Interfaces:
RandomGenerator
,RandomGenerator.StreamableGenerator
- Direct Known Subclasses:
EnhancedJumpableGenerator
,EnhancedSplittableGenerator
RandomGenerator.StreamableGenerator
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.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
ConstructorDescriptionConstructs 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 TypeMethodDescriptionerngs()
Gets an effectively unlimited stream ofEnhancedRandomGenerator
objects, each wrapping an object of the same random number generator algorithm as this one.erngs
(long streamSize) Gets a stream ofEnhancedRandomGenerator
objects, each wrapping an object of the same random number generator algorithm as this one.static EnhancedStreamableGenerator
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.rngs()
Gets an effectively unlimited stream ofEnhancedRandomGenerator
objects, each wrapping an object of the same random number generator algorithm as this one.rngs
(long streamSize) Gets a stream ofEnhancedRandomGenerator
objects, 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, 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
-
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 ofEnhancedRandomGenerator
objects, 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 ofEnhancedRandomGenerator
objects, 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 ofEnhancedRandomGenerator
objects, each wrapping an object of the same random number generator algorithm as this one.The implementation of this method from the
RandomGenerator.StreamableGenerator
interface returns a stream ofEnhancedRandomGenerator
objects, 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:
rngs
in interfaceRandomGenerator.StreamableGenerator
- Returns:
- a stream of EnhancedRandomGenerator objects
-
rngs
Gets a stream ofEnhancedRandomGenerator
objects, each wrapping an object of the same random number generator algorithm as this one.The implementation of this method from the
RandomGenerator.StreamableGenerator
interface returns a stream ofEnhancedRandomGenerator
objects, 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:
rngs
in interfaceRandomGenerator.StreamableGenerator
- Parameters:
streamSize
- the number of EnhancedRandomGenerator objects in the stream- Returns:
- a stream of EnhancedRandomGenerator objects
-