Interface SplittableUniformRandomProvider
-
- All Superinterfaces:
UniformRandomProvider
public interface SplittableUniformRandomProvider extends UniformRandomProvider
Applies to generators that can be split into two objects (the original and a new instance) each of which implements the same interface (and can be recursively split indefinitely). It is assumed that the two generators resulting from a split can be used concurrently on different threads.Ideally all generators produced by recursive splitting from the original object are statistically independent and individually uniform. In this case it would be expected that the set of values collectively generated from a group of split generators would have the same statistical properties as the same number of values produced from a single generator object.
- Since:
- 1.5
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default DoubleStreamdoubles()Returns an effectively unlimited stream ofdoublevalues between 0 (inclusive) and 1 (exclusive).default DoubleStreamdoubles(double origin, double bound)Returns an effectively unlimited stream ofdoublevalues between the specifiedorigin(inclusive) and the specifiedbound(exclusive).default DoubleStreamdoubles(long streamSize)Returns a stream producing the givenstreamSizenumber ofdoublevalues between 0 (inclusive) and 1 (exclusive).default DoubleStreamdoubles(long streamSize, double origin, double bound)Returns a stream producing the givenstreamSizenumber ofdoublevalues between the specifiedorigin(inclusive) and the specifiedbound(exclusive).default IntStreamints()Returns an effectively unlimited stream ofintvalues.default IntStreamints(int origin, int bound)Returns an effectively unlimited stream ofintvalues between the specifiedorigin(inclusive) and the specifiedbound(exclusive).default IntStreamints(long streamSize)Returns a stream producing the givenstreamSizenumber ofintvalues.default IntStreamints(long streamSize, int origin, int bound)Returns a stream producing the givenstreamSizenumber ofintvalues between the specifiedorigin(inclusive) and the specifiedbound(exclusive).default LongStreamlongs()Returns an effectively unlimited stream oflongvalues.default LongStreamlongs(long streamSize)Returns a stream producing the givenstreamSizenumber oflongvalues.default LongStreamlongs(long origin, long bound)Returns an effectively unlimited stream oflongvalues between the specifiedorigin(inclusive) and the specifiedbound(exclusive).default LongStreamlongs(long streamSize, long origin, long bound)Returns a stream producing the givenstreamSizenumber oflongvalues between the specifiedorigin(inclusive) and the specifiedbound(exclusive).default SplittableUniformRandomProvidersplit()Creates a new random generator, split off from this one, that implements theSplittableUniformRandomProviderinterface.SplittableUniformRandomProvidersplit(UniformRandomProvider source)Creates a new random generator, split off from this one, that implements theSplittableUniformRandomProviderinterface.default Stream<SplittableUniformRandomProvider>splits()Returns an effectively unlimited stream of new random generators, each of which implements theSplittableUniformRandomProviderinterface.default Stream<SplittableUniformRandomProvider>splits(long streamSize)Returns a stream producing the givenstreamSizenumber of new random generators, each of which implements theSplittableUniformRandomProviderinterface.default Stream<SplittableUniformRandomProvider>splits(long streamSize, SplittableUniformRandomProvider source)Returns a stream producing the givenstreamSizenumber of new random generators, each of which implements theSplittableUniformRandomProviderinterface.default Stream<SplittableUniformRandomProvider>splits(SplittableUniformRandomProvider source)Returns an effectively unlimited stream of new random generators, each of which implements theSplittableUniformRandomProviderinterface.-
Methods inherited from interface org.apache.commons.rng.UniformRandomProvider
nextBoolean, nextBytes, nextBytes, nextDouble, nextDouble, nextDouble, nextFloat, nextFloat, nextFloat, nextInt, nextInt, nextInt, nextLong, nextLong, nextLong
-
-
-
-
Method Detail
-
split
default SplittableUniformRandomProvider split()
Creates a new random generator, split off from this one, that implements theSplittableUniformRandomProviderinterface.The current generator may be used a source of randomness to initialise the new instance. In this case repeat invocations of this method will return objects with a different initial state that are expected to be statistically independent.
- Returns:
- A new instance.
-
split
SplittableUniformRandomProvider split(UniformRandomProvider source)
Creates a new random generator, split off from this one, that implements theSplittableUniformRandomProviderinterface.- Parameters:
source- A source of randomness used to initialise the new instance.- Returns:
- A new instance.
- Throws:
NullPointerException- ifsourceis null
-
splits
default Stream<SplittableUniformRandomProvider> splits()
Returns an effectively unlimited stream of new random generators, each of which implements theSplittableUniformRandomProviderinterface.The current generator may be used a source of randomness to initialise the new instances.
- Returns:
- a stream of random generators.
-
splits
default Stream<SplittableUniformRandomProvider> splits(SplittableUniformRandomProvider source)
Returns an effectively unlimited stream of new random generators, each of which implements theSplittableUniformRandomProviderinterface.- Parameters:
source- A source of randomness used to initialise the new instances; this may be split to provide a source of randomness across a parallel stream.- Returns:
- a stream of random generators.
- Throws:
NullPointerException- ifsourceis null
-
splits
default Stream<SplittableUniformRandomProvider> splits(long streamSize)
Returns a stream producing the givenstreamSizenumber of new random generators, each of which implements theSplittableUniformRandomProviderinterface.The current generator may be used a source of randomness to initialise the new instances.
- Parameters:
streamSize- Number of objects to generate.- Returns:
- a stream of random generators; the stream is limited to the given
streamSize. - Throws:
IllegalArgumentException- ifstreamSizeis negative.
-
splits
default Stream<SplittableUniformRandomProvider> splits(long streamSize, SplittableUniformRandomProvider source)
Returns a stream producing the givenstreamSizenumber of new random generators, each of which implements theSplittableUniformRandomProviderinterface.- Parameters:
streamSize- Number of objects to generate.source- A source of randomness used to initialise the new instances; this may be split to provide a source of randomness across a parallel stream.- Returns:
- a stream of random generators; the stream is limited to the given
streamSize. - Throws:
IllegalArgumentException- ifstreamSizeis negative.NullPointerException- ifsourceis null
-
ints
default IntStream ints()
Description copied from interface:UniformRandomProviderReturns an effectively unlimited stream ofintvalues.- Specified by:
intsin interfaceUniformRandomProvider- Returns:
- a stream of random
intvalues.
-
ints
default IntStream ints(int origin, int bound)
Description copied from interface:UniformRandomProviderReturns an effectively unlimited stream ofintvalues between the specifiedorigin(inclusive) and the specifiedbound(exclusive).- Specified by:
intsin interfaceUniformRandomProvider- Parameters:
origin- Lower bound on the random number to be returned.bound- Upper bound (exclusive) on the random number to be returned.- Returns:
- a stream of random values between the specified
origin(inclusive) and the specifiedbound(exclusive).
-
ints
default IntStream ints(long streamSize)
Description copied from interface:UniformRandomProviderReturns a stream producing the givenstreamSizenumber ofintvalues.- Specified by:
intsin interfaceUniformRandomProvider- Parameters:
streamSize- Number of values to generate.- Returns:
- a stream of random
intvalues; the stream is limited to the givenstreamSize.
-
ints
default IntStream ints(long streamSize, int origin, int bound)
Description copied from interface:UniformRandomProviderReturns a stream producing the givenstreamSizenumber ofintvalues between the specifiedorigin(inclusive) and the specifiedbound(exclusive).- Specified by:
intsin interfaceUniformRandomProvider- Parameters:
streamSize- Number of values to generate.origin- Lower bound on the random number to be returned.bound- Upper bound (exclusive) on the random number to be returned.- Returns:
- a stream of random values between the specified
origin(inclusive) and the specifiedbound(exclusive); the stream is limited to the givenstreamSize.
-
longs
default LongStream longs()
Description copied from interface:UniformRandomProviderReturns an effectively unlimited stream oflongvalues.- Specified by:
longsin interfaceUniformRandomProvider- Returns:
- a stream of random
longvalues.
-
longs
default LongStream longs(long origin, long bound)
Description copied from interface:UniformRandomProviderReturns an effectively unlimited stream oflongvalues between the specifiedorigin(inclusive) and the specifiedbound(exclusive).- Specified by:
longsin interfaceUniformRandomProvider- Parameters:
origin- Lower bound on the random number to be returned.bound- Upper bound (exclusive) on the random number to be returned.- Returns:
- a stream of random values between the specified
origin(inclusive) and the specifiedbound(exclusive).
-
longs
default LongStream longs(long streamSize)
Description copied from interface:UniformRandomProviderReturns a stream producing the givenstreamSizenumber oflongvalues.- Specified by:
longsin interfaceUniformRandomProvider- Parameters:
streamSize- Number of values to generate.- Returns:
- a stream of random
longvalues; the stream is limited to the givenstreamSize.
-
longs
default LongStream longs(long streamSize, long origin, long bound)
Description copied from interface:UniformRandomProviderReturns a stream producing the givenstreamSizenumber oflongvalues between the specifiedorigin(inclusive) and the specifiedbound(exclusive).- Specified by:
longsin interfaceUniformRandomProvider- Parameters:
streamSize- Number of values to generate.origin- Lower bound on the random number to be returned.bound- Upper bound (exclusive) on the random number to be returned.- Returns:
- a stream of random values between the specified
origin(inclusive) and the specifiedbound(exclusive); the stream is limited to the givenstreamSize.
-
doubles
default DoubleStream doubles()
Description copied from interface:UniformRandomProviderReturns an effectively unlimited stream ofdoublevalues between 0 (inclusive) and 1 (exclusive).- Specified by:
doublesin interfaceUniformRandomProvider- Returns:
- a stream of random values between 0 (inclusive) and 1 (exclusive).
-
doubles
default DoubleStream doubles(double origin, double bound)
Description copied from interface:UniformRandomProviderReturns an effectively unlimited stream ofdoublevalues between the specifiedorigin(inclusive) and the specifiedbound(exclusive).- Specified by:
doublesin interfaceUniformRandomProvider- Parameters:
origin- Lower bound on the random number to be returned.bound- Upper bound (exclusive) on the random number to be returned.- Returns:
- a stream of random values between the specified
origin(inclusive) and the specifiedbound(exclusive).
-
doubles
default DoubleStream doubles(long streamSize)
Description copied from interface:UniformRandomProviderReturns a stream producing the givenstreamSizenumber ofdoublevalues between 0 (inclusive) and 1 (exclusive).- Specified by:
doublesin interfaceUniformRandomProvider- Parameters:
streamSize- Number of values to generate.- Returns:
- a stream of random values between 0 (inclusive) and 1 (exclusive);
the stream is limited to the given
streamSize.
-
doubles
default DoubleStream doubles(long streamSize, double origin, double bound)
Description copied from interface:UniformRandomProviderReturns a stream producing the givenstreamSizenumber ofdoublevalues between the specifiedorigin(inclusive) and the specifiedbound(exclusive).- Specified by:
doublesin interfaceUniformRandomProvider- Parameters:
streamSize- Number of values to generate.origin- Lower bound on the random number to be returned.bound- Upper bound (exclusive) on the random number to be returned.- Returns:
- a stream of random values between the specified
origin(inclusive) and the specifiedbound(exclusive); the stream is limited to the givenstreamSize.
-
-