Package org.apache.commons.rng
Interface UniformRandomProvider
-
- All Known Subinterfaces:
JumpableUniformRandomProvider,LongJumpableUniformRandomProvider,RestorableUniformRandomProvider,SplittableUniformRandomProvider
public interface UniformRandomProvider
Applies to generators of random number sequences that follow a uniform distribution.- Since:
- 1.0
-
-
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 booleannextBoolean()Generates abooleanvalue.default voidnextBytes(byte[] bytes)Generatesbytevalues and places them into a user-supplied array.default voidnextBytes(byte[] bytes, int start, int len)Generatesbytevalues and places them into a user-supplied array.default doublenextDouble()Generates adoublevalue between 0 (inclusive) and 1 (exclusive).default doublenextDouble(double bound)Generates adoublevalue between 0 (inclusive) and the specifiedbound(exclusive).default doublenextDouble(double origin, double bound)Generates adoublevalue between the specifiedorigin(inclusive) and the specifiedbound(exclusive).default floatnextFloat()Generates afloatvalue between 0 (inclusive) and 1 (exclusive).default floatnextFloat(float bound)Generates afloatvalue between 0 (inclusive) and the specifiedbound(exclusive).default floatnextFloat(float origin, float bound)Generates afloatvalue between the specifiedorigin(inclusive) and the specifiedbound(exclusive).default intnextInt()Generates anintvalue.default intnextInt(int n)Generates anintvalue between 0 (inclusive) and the specified value (exclusive).default intnextInt(int origin, int bound)Generates anintvalue between the specifiedorigin(inclusive) and the specifiedbound(exclusive).longnextLong()Generates alongvalue.default longnextLong(long n)Generates alongvalue between 0 (inclusive) and the specified value (exclusive).default longnextLong(long origin, long bound)Generates alongvalue between the specifiedorigin(inclusive) and the specifiedbound(exclusive).
-
-
-
Method Detail
-
nextBytes
default void nextBytes(byte[] bytes)
Generatesbytevalues and places them into a user-supplied array.The number of random bytes produced is equal to the length of the byte array.
- Parameters:
bytes- Byte array in which to put the random bytes. Cannot benull.
-
nextBytes
default void nextBytes(byte[] bytes, int start, int len)
Generatesbytevalues and places them into a user-supplied array.The array is filled with bytes extracted from random integers. This implies that the number of random bytes generated may be larger than the length of the byte array.
- Parameters:
bytes- Array in which to put the generated bytes. Cannot benull.start- Index at which to start inserting the generated bytes.len- Number of bytes to insert.- Throws:
IndexOutOfBoundsException- ifstart < 0orstart >= bytes.length.IndexOutOfBoundsException- iflen < 0orlen > bytes.length - start.
-
nextInt
default int nextInt()
Generates anintvalue.- Returns:
- the next random value.
-
nextInt
default int nextInt(int n)
Generates anintvalue between 0 (inclusive) and the specified value (exclusive).- Parameters:
n- Bound on the random number to be returned. Must be positive.- Returns:
- a random
intvalue between 0 (inclusive) andn(exclusive). - Throws:
IllegalArgumentException- ifnis not above zero.
-
nextInt
default int nextInt(int origin, int bound)
Generates anintvalue between the specifiedorigin(inclusive) and the specifiedbound(exclusive).- Parameters:
origin- Lower bound on the random number to be returned.bound- Upper bound (exclusive) on the random number to be returned.- Returns:
- a random
intvalue betweenorigin(inclusive) andbound(exclusive). - Throws:
IllegalArgumentException- iforiginis greater than or equal tobound.- Since:
- 1.5
-
nextLong
long nextLong()
Generates alongvalue.- Returns:
- the next random value.
-
nextLong
default long nextLong(long n)
Generates alongvalue between 0 (inclusive) and the specified value (exclusive).- Parameters:
n- Bound on the random number to be returned. Must be positive.- Returns:
- a random
longvalue between 0 (inclusive) andn(exclusive). - Throws:
IllegalArgumentException- ifnis not greater than 0.
-
nextLong
default long nextLong(long origin, long bound)
Generates alongvalue between the specifiedorigin(inclusive) and the specifiedbound(exclusive).- Parameters:
origin- Lower bound on the random number to be returned.bound- Upper bound (exclusive) on the random number to be returned.- Returns:
- a random
longvalue betweenorigin(inclusive) andbound(exclusive). - Throws:
IllegalArgumentException- iforiginis greater than or equal tobound.- Since:
- 1.5
-
nextBoolean
default boolean nextBoolean()
Generates abooleanvalue.- Returns:
- the next random value.
-
nextFloat
default float nextFloat()
Generates afloatvalue between 0 (inclusive) and 1 (exclusive).- Returns:
- the next random value between 0 (inclusive) and 1 (exclusive).
-
nextFloat
default float nextFloat(float bound)
Generates afloatvalue between 0 (inclusive) and the specifiedbound(exclusive).- Parameters:
bound- Upper bound (exclusive) on the random number to be returned.- Returns:
- a random
floatvalue between 0 (inclusive) andbound(exclusive). - Throws:
IllegalArgumentException- ifboundis not both finite and greater than 0.- Since:
- 1.5
-
nextFloat
default float nextFloat(float origin, float bound)
Generates afloatvalue between the specifiedorigin(inclusive) and the specifiedbound(exclusive).- Parameters:
origin- Lower bound on the random number to be returned.bound- Upper bound (exclusive) on the random number to be returned.- Returns:
- a random
floatvalue betweenorigin(inclusive) andbound(exclusive). - Throws:
IllegalArgumentException- iforiginis not finite, orboundis not finite, ororiginis greater than or equal tobound.- Since:
- 1.5
-
nextDouble
default double nextDouble()
Generates adoublevalue between 0 (inclusive) and 1 (exclusive).- Returns:
- the next random value between 0 (inclusive) and 1 (exclusive).
-
nextDouble
default double nextDouble(double bound)
Generates adoublevalue between 0 (inclusive) and the specifiedbound(exclusive).- Parameters:
bound- Upper bound (exclusive) on the random number to be returned.- Returns:
- a random
doublevalue between 0 (inclusive) andbound(exclusive). - Throws:
IllegalArgumentException- ifboundis not both finite and greater than 0.- Since:
- 1.5
-
nextDouble
default double nextDouble(double origin, double bound)
Generates adoublevalue between the specifiedorigin(inclusive) and the specifiedbound(exclusive).- Parameters:
origin- Lower bound on the random number to be returned.bound- Upper bound (exclusive) on the random number to be returned.- Returns:
- a random
doublevalue betweenorigin(inclusive) andbound(exclusive). - Throws:
IllegalArgumentException- iforiginis not finite, orboundis not finite, ororiginis greater than or equal tobound.- Since:
- 1.5
-
ints
default IntStream ints()
Returns an effectively unlimited stream ofintvalues.- Returns:
- a stream of random
intvalues. - Since:
- 1.5
-
ints
default IntStream ints(int origin, int bound)
Returns an effectively unlimited stream ofintvalues between the specifiedorigin(inclusive) and the specifiedbound(exclusive).- 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). - Throws:
IllegalArgumentException- iforiginis greater than or equal tobound.- Since:
- 1.5
-
ints
default IntStream ints(long streamSize)
Returns a stream producing the givenstreamSizenumber ofintvalues.- Parameters:
streamSize- Number of values to generate.- Returns:
- a stream of random
intvalues; the stream is limited to the givenstreamSize. - Throws:
IllegalArgumentException- ifstreamSizeis negative.- Since:
- 1.5
-
ints
default IntStream ints(long streamSize, int origin, int bound)
Returns a stream producing the givenstreamSizenumber ofintvalues between the specifiedorigin(inclusive) and the specifiedbound(exclusive).- 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. - Throws:
IllegalArgumentException- ifstreamSizeis negative, or iforiginis greater than or equal tobound.- Since:
- 1.5
-
longs
default LongStream longs()
Returns an effectively unlimited stream oflongvalues.- Returns:
- a stream of random
longvalues. - Since:
- 1.5
-
longs
default LongStream longs(long origin, long bound)
Returns an effectively unlimited stream oflongvalues between the specifiedorigin(inclusive) and the specifiedbound(exclusive).- 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). - Throws:
IllegalArgumentException- iforiginis greater than or equal tobound.- Since:
- 1.5
-
longs
default LongStream longs(long streamSize)
Returns a stream producing the givenstreamSizenumber oflongvalues.- Parameters:
streamSize- Number of values to generate.- Returns:
- a stream of random
longvalues; the stream is limited to the givenstreamSize. - Throws:
IllegalArgumentException- ifstreamSizeis negative.- Since:
- 1.5
-
longs
default LongStream longs(long streamSize, long origin, long bound)
Returns a stream producing the givenstreamSizenumber oflongvalues between the specifiedorigin(inclusive) and the specifiedbound(exclusive).- 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. - Throws:
IllegalArgumentException- ifstreamSizeis negative, or iforiginis greater than or equal tobound.- Since:
- 1.5
-
doubles
default DoubleStream doubles()
Returns an effectively unlimited stream ofdoublevalues between 0 (inclusive) and 1 (exclusive).- Returns:
- a stream of random values between 0 (inclusive) and 1 (exclusive).
- Since:
- 1.5
-
doubles
default DoubleStream doubles(double origin, double bound)
Returns an effectively unlimited stream ofdoublevalues between the specifiedorigin(inclusive) and the specifiedbound(exclusive).- 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). - Throws:
IllegalArgumentException- iforiginis not finite, orboundis not finite, ororiginis greater than or equal tobound.- Since:
- 1.5
-
doubles
default DoubleStream doubles(long streamSize)
Returns a stream producing the givenstreamSizenumber ofdoublevalues between 0 (inclusive) and 1 (exclusive).- 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. - Throws:
IllegalArgumentException- ifstreamSizeis negative.- Since:
- 1.5
-
doubles
default DoubleStream doubles(long streamSize, double origin, double bound)
Returns a stream producing the givenstreamSizenumber ofdoublevalues between the specifiedorigin(inclusive) and the specifiedbound(exclusive).- 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. - Throws:
IllegalArgumentException- ifstreamSizeis negative, or iforiginis not finite, orboundis not finite, ororiginis greater than or equal tobound.- Since:
- 1.5
-
-