Package org.apache.commons.rng
Interface UniformRandomProvider
-
- All Known Subinterfaces:
JumpableUniformRandomProvider,LongJumpableUniformRandomProvider,RestorableUniformRandomProvider
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 Modifier and Type Method Description booleannextBoolean()Generates abooleanvalue.voidnextBytes(byte[] bytes)Generatesbytevalues and places them into a user-supplied array.voidnextBytes(byte[] bytes, int start, int len)Generatesbytevalues and places them into a user-supplied array.doublenextDouble()Generates adoublevalue between 0 and 1.floatnextFloat()Generates afloatvalue between 0 and 1.intnextInt()Generates anintvalue.intnextInt(int n)Generates anintvalue between 0 (inclusive) and the specified value (exclusive).longnextLong()Generates alongvalue.longnextLong(long n)Generates alongvalue between 0 (inclusive) and the specified value (exclusive).
-
-
-
Method Detail
-
nextBytes
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 the byte array.
- Parameters:
bytes- Byte array in which to put the random bytes. Cannot benull.
-
nextBytes
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
int nextInt()
Generates anintvalue.- Returns:
- the next random value.
-
nextInt
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 negative.
-
nextLong
long nextLong()
Generates alongvalue.- Returns:
- the next random value.
-
nextLong
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 negative.
-
nextBoolean
boolean nextBoolean()
Generates abooleanvalue.- Returns:
- the next random value.
-
nextFloat
float nextFloat()
Generates afloatvalue between 0 and 1.- Returns:
- the next random value between 0 and 1.
-
nextDouble
double nextDouble()
Generates adoublevalue between 0 and 1.- Returns:
- the next random value between 0 and 1.
-
-