- All Implemented Interfaces:
RandomGenerator
,RandomGenerator.SplittableGenerator
,RandomGenerator.StreamableGenerator
RandomGenerator.SplittableGenerator
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.SplittableGenerator
interface, such as splits()
, that return streams of RandomGenerator.SplittableGenerator are implemented to return
streams of EnhancedSplittableGenerator objects that wrap the RandomGenerator.SplittableGenerator
objects in the streams returned by the enclosed RandomGenerator.SplittableGenerator. However,
additionally this class provides a counterpart, such as esplits()
, for each of these whose
return type is explicitly a stream of EnhancedSplittableGenerator 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 EnhancedSplittableGenerator to wrap an instance of a default SplittableGenerator.EnhancedSplittableGenerator
(long seed) Constructs the EnhancedSplittableGenerator 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.EnhancedSplittableGenerator
(String algorithmName) Constructs the EnhancedSplittableGenerator to wrap an instance of any random number generator supported by your version of Java as specified by its name, as documented via theRandomGenerator.SplittableGenerator.of(java.lang.String)
method.Constructs an EnhancedSplittableGenerator to wrap and enhance a givenRandomGenerator.SplittableGenerator
. -
Method Summary
Modifier and TypeMethodDescriptionfinal Stream<EnhancedRandomGenerator>
erngs()
Gets an effectively unlimited stream ofEnhancedRandomGenerator
objects, each wrapping an object of the same random number generator algorithm as this one.final Stream<EnhancedRandomGenerator>
erngs
(long streamSize) Gets a stream ofEnhancedRandomGenerator
objects, each wrapping an object of the same random number generator algorithm as this one.esplits()
Gets an effectively unlimited stream ofEnhancedSplittableGenerator
objects.esplits
(long streamSize) Gets a stream ofEnhancedSplittableGenerator
objects.esplits
(long streamSize, RandomGenerator.SplittableGenerator source) Gets a stream ofEnhancedSplittableGenerator
objects.Gets an effectively unlimited stream ofEnhancedSplittableGenerator
objects.static EnhancedSplittableGenerator
Gets an EnhancedSplittableGenerator wrapping an instance of any random number generator supported by your version of Java as specified by its name, as documented via theRandomGenerator.SplittableGenerator.of(java.lang.String)
method.final Stream<RandomGenerator>
rngs()
Gets an effectively unlimited stream ofEnhancedRandomGenerator
objects, each wrapping an object of the same random number generator algorithm as this one.final Stream<RandomGenerator>
rngs
(long streamSize) Gets a stream ofEnhancedRandomGenerator
objects, each wrapping an object of the same random number generator algorithm as this one.split()
Returns a new EnhancedSplittableGenerator split off from this one, such that the new one wraps a split of the wrapped random number generator.Returns a new EnhancedSplittableGenerator split off from this one, such that the new one wraps a split of the wrapped random number generator.splits()
Gets an effectively unlimited stream ofEnhancedSplittableGenerator
objects.splits
(long streamSize) Gets a stream ofEnhancedSplittableGenerator
objects.splits
(long streamSize, RandomGenerator.SplittableGenerator source) Gets a stream ofEnhancedSplittableGenerator
objects.Gets an effectively unlimited stream ofEnhancedSplittableGenerator
objects.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
-
EnhancedSplittableGenerator
public EnhancedSplittableGenerator()Constructs the EnhancedSplittableGenerator to wrap an instance of a default SplittableGenerator. 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. -
EnhancedSplittableGenerator
public EnhancedSplittableGenerator(long seed) Constructs the EnhancedSplittableGenerator 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.
-
EnhancedSplittableGenerator
Constructs an EnhancedSplittableGenerator to wrap and enhance a givenRandomGenerator.SplittableGenerator
.- Parameters:
generator
- the RandomGenerator.SplittableGenerator to wrap and enhance.
-
EnhancedSplittableGenerator
Constructs the EnhancedSplittableGenerator to wrap an instance of any random number generator supported by your version of Java as specified by its name, as documented via theRandomGenerator.SplittableGenerator.of(java.lang.String)
method.- Parameters:
algorithmName
- The name of the random number generator as documented by theRandomGenerator.SplittableGenerator.of(java.lang.String)
method.- Throws:
NullPointerException
- if algorithmName is null.IllegalArgumentException
- if algorithmName is not found.
-
-
Method Details
-
of
Gets an EnhancedSplittableGenerator wrapping an instance of any random number generator supported by your version of Java as specified by its name, as documented via theRandomGenerator.SplittableGenerator.of(java.lang.String)
method.- Parameters:
algorithmName
- The name of the random number generator as documented by theRandomGenerator.SplittableGenerator.of(java.lang.String)
method.- Returns:
- an EnhancedSplittableGenerator wrapping an instance of your chosen random number generator.
- Throws:
NullPointerException
- if algorithmName is null.IllegalArgumentException
- if algorithmName is not found.
-
split
Returns a new EnhancedSplittableGenerator split off from this one, such that the new one wraps a split of the wrapped random number generator.- Specified by:
split
in interfaceRandomGenerator.SplittableGenerator
- Returns:
- a new EnhancedSplittableGenerator split off from this one
-
split
Returns a new EnhancedSplittableGenerator split off from this one, such that the new one wraps a split of the wrapped random number generator.- Specified by:
split
in interfaceRandomGenerator.SplittableGenerator
- Parameters:
source
- The source of randomness used to initialize the split rather than this one.- Returns:
- a new EnhancedSplittableGenerator split off from this one
-
esplits
Gets an effectively unlimited stream ofEnhancedSplittableGenerator
objects.The behavior of this method is identical to that of
splits()
, but may be more convenient to use due to explicit return type of a stream of EnhancedSplittableGenerator objects.- Returns:
- a stream of EnhancedSplittableGenerator objects
-
esplits
Gets a stream ofEnhancedSplittableGenerator
objects.The behavior of this method is identical to that of
splits(long)
, but may be more convenient to use due to explicit return type of a stream of EnhancedSplittableGenerator objects.- Parameters:
streamSize
- the number of EnhancedSplittableGenerator objects in the stream- Returns:
- a stream of EnhancedSplittableGenerator objects
-
esplits
public final Stream<EnhancedSplittableGenerator> esplits(long streamSize, RandomGenerator.SplittableGenerator source) Gets a stream ofEnhancedSplittableGenerator
objects.The behavior of this method is identical to that of
splits(long, RandomGenerator.SplittableGenerator)
, but may be more convenient to use due to explicit return type of a stream of EnhancedSplittableGenerator objects.- Parameters:
streamSize
- the number of EnhancedSplittableGenerator objects in the streamsource
- The source of randomness used to initialize the splits rather than this one.- Returns:
- a stream of EnhancedSplittableGenerator objects
-
esplits
public final Stream<EnhancedSplittableGenerator> esplits(RandomGenerator.SplittableGenerator source) Gets an effectively unlimited stream ofEnhancedSplittableGenerator
objects.The behavior of this method is identical to that of
splits(RandomGenerator.SplittableGenerator)
, but may be more convenient to use due to explicit return type of a stream of EnhancedSplittableGenerator objects.- Parameters:
source
- The source of randomness used to initialize the splits rather than this one.- Returns:
- a stream of EnhancedSplittableGenerator objects
-
splits
Gets an effectively unlimited stream ofEnhancedSplittableGenerator
objects.The implementation of this method from the
RandomGenerator.SplittableGenerator
interface returns a stream ofEnhancedSplittableGenerator
objects, and is thus safe to cast the objects of the stream toEnhancedSplittableGenerator
. However, you may find it more convenient to instead utilize theesplits()
method, whose behavior is identical aside from the return type.- Specified by:
splits
in interfaceRandomGenerator.SplittableGenerator
- Returns:
- a stream of EnhancedSplittableGenerator objects
-
splits
Gets a stream ofEnhancedSplittableGenerator
objects.The implementation of this method from the
RandomGenerator.SplittableGenerator
interface returns a stream ofEnhancedSplittableGenerator
objects, and is thus safe to cast the objects of the stream toEnhancedSplittableGenerator
. However, you may find it more convenient to instead utilize theesplits(long)
method, whose behavior is identical aside from the return type.- Specified by:
splits
in interfaceRandomGenerator.SplittableGenerator
- Parameters:
streamSize
- the number of EnhancedSplittableGenerator objects in the stream- Returns:
- a stream of EnhancedSplittableGenerator objects
-
splits
public final Stream<RandomGenerator.SplittableGenerator> splits(long streamSize, RandomGenerator.SplittableGenerator source) Gets a stream ofEnhancedSplittableGenerator
objects.The implementation of this method from the
RandomGenerator.SplittableGenerator
interface returns a stream ofEnhancedSplittableGenerator
objects, and is thus safe to cast the objects of the stream toEnhancedSplittableGenerator
. However, you may find it more convenient to instead utilize theesplits(long, RandomGenerator.SplittableGenerator)
method, whose behavior is identical aside from the return type.- Specified by:
splits
in interfaceRandomGenerator.SplittableGenerator
- Parameters:
streamSize
- the number of EnhancedSplittableGenerator objects in the streamsource
- The source of randomness used to initialize the splits rather than this one.- Returns:
- a stream of EnhancedSplittableGenerator objects
-
splits
public final Stream<RandomGenerator.SplittableGenerator> splits(RandomGenerator.SplittableGenerator source) Gets an effectively unlimited stream ofEnhancedSplittableGenerator
objects.The implementation of this method from the
RandomGenerator.SplittableGenerator
interface returns a stream ofEnhancedSplittableGenerator
objects, and is thus safe to cast the objects of the stream toEnhancedSplittableGenerator
. However, you may find it more convenient to instead utilize theesplits(RandomGenerator.SplittableGenerator)
method, whose behavior is identical aside from the return type.- Specified by:
splits
in interfaceRandomGenerator.SplittableGenerator
- Parameters:
source
- The source of randomness used to initialize the splits rather than this one.- Returns:
- a stream of EnhancedSplittableGenerator objects
-
erngs
Description copied from class:EnhancedStreamableGenerator
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
EnhancedStreamableGenerator.rngs()
, but may be more convenient to use due to explicit return type of a stream of EnhancedRandomGenerator objects.- Overrides:
erngs
in classEnhancedStreamableGenerator
- Returns:
- a stream of EnhancedRandomGenerator objects
-
erngs
Description copied from class:EnhancedStreamableGenerator
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
EnhancedStreamableGenerator.rngs(long)
, but may be more convenient to use due to explicit return type of a stream of EnhancedRandomGenerator objects.- Overrides:
erngs
in classEnhancedStreamableGenerator
- Parameters:
streamSize
- the number of EnhancedRandomGenerator objects in the stream- Returns:
- a stream of EnhancedRandomGenerator objects
-
rngs
Description copied from class:EnhancedStreamableGenerator
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 theEnhancedStreamableGenerator.erngs()
method, whose behavior is identical aside from the return type.- Specified by:
rngs
in interfaceRandomGenerator.SplittableGenerator
- Specified by:
rngs
in interfaceRandomGenerator.StreamableGenerator
- Overrides:
rngs
in classEnhancedStreamableGenerator
- Returns:
- a stream of EnhancedRandomGenerator objects
-
rngs
Description copied from class:EnhancedStreamableGenerator
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 theEnhancedStreamableGenerator.erngs(long)
method, whose behavior is identical aside from the return type.- Specified by:
rngs
in interfaceRandomGenerator.SplittableGenerator
- Specified by:
rngs
in interfaceRandomGenerator.StreamableGenerator
- Overrides:
rngs
in classEnhancedStreamableGenerator
- Parameters:
streamSize
- the number of EnhancedRandomGenerator objects in the stream- Returns:
- a stream of EnhancedRandomGenerator objects
-