Package org.apache.commons.rng
Interface UniformRandomProvider
-
- All Known Subinterfaces:
RestorableUniformRandomProvider
- All Known Implementing Classes:
AbstractWell,BaseProvider,IntProvider,ISAACRandom,JDKRandom,KISSRandom,LongProvider,MersenneTwister,MersenneTwister64,MultiplyWithCarry256,SplitMix64,TwoCmres,Well1024a,Well19937a,Well19937c,Well44497a,Well44497b,Well512a,XoRoShiRo128Plus,XoRoShiRo128StarStar,XoRoShiRo64Star,XoRoShiRo64StarStar,XorShift1024Star,XorShift1024StarPhi,XoShiRo128Plus,XoShiRo128StarStar,XoShiRo256Plus,XoShiRo256StarStar,XoShiRo512Plus,XoShiRo512StarStar
public interface UniformRandomProviderApplies to generators of random number sequences that follow a uniform distribution.- Since:
- 1.0
-
-
Method Summary
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:
java.lang.IndexOutOfBoundsException- ifstart < 0orstart >= bytes.length.java.lang.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:
java.lang.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:
java.lang.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.
-
-