- All Implemented Interfaces:
RandomGenerator
,RandomGenerator.SplittableGenerator
,RandomGenerator.StreamableGenerator
RandomGenerator.SplittableGenerator
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.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 TypeMethodDescriptionesplits()
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.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.EnhancedStreamableGenerator
erngs, erngs, rngs, rngs
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, sampleReservoir
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
Methods inherited from interface java.util.random.RandomGenerator.SplittableGenerator
rngs, rngs
-
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
-