com.newisys.random
Interface PRNG

All Superinterfaces:
Cloneable, PRNGProvider, Serializable

public interface PRNG
extends PRNGProvider

Pseudorandom number generator interface.


Method Summary
 PRNG clone()
          Returns a new instance of this PRNG with the same state, meaning that each instance will independently generate the same sequence.
 PRNGProvider getPRNGProvider()
           
 int nextBits(int bits)
          Returns an int containing the given number of random bits.
 BitVector nextBitVector(int numBits)
          Returns the next pseudorandom, uniformly distributed BitVector value between 0 and 2numBits.
 boolean nextBoolean()
          Returns the next pseudorandom, uniformly distributed boolean value from the generator's sequence.
 boolean nextBoolean(double probability)
          Returns a pseudorandom boolean value from the generator's sequence with the given probability that it will be true.
 boolean nextBoolean(float probability)
          Returns a pseudorandom boolean value from the generator's sequence with the given probability that it will be true.
 double nextDouble()
          Returns the next pseudorandom, uniformly distributed double value between 0.0 and 1.0 from the generator's sequence.
 float nextFloat()
          Returns the next pseudorandom, uniformly distributed float value between 0.0 and 1.0 from the generator's sequence.
 int nextInt()
          Returns the next pseudorandom, uniformly distributed int value from the generator's sequence.
 int nextInt(int limit)
          Returns the next pseudorandom, uniformly distributed, positive int value between 0 (inclusive) and limit (exclusive) from the generator's sequence.
 int nextInt(int min, int max)
          Returns the next pseudorandom, uniformly distributed int value between min and max (inclusive) from the generator's sequence.
 void nextInts(int[] array, int start, int count)
          Fills the given array with random ints, as if nextBits(32) were called for each element.
 long nextLong()
          Returns the next pseudorandom, uniformly distributed long value from the generator's sequence.
 

Method Detail

getPRNGProvider

PRNGProvider getPRNGProvider()

nextBits

int nextBits(int bits)
Description copied from interface: PRNGProvider
Returns an int containing the given number of random bits. Some random number generators will produce a fixed number of random bits each time this method is called, and discard any unneeded bits, so it may not be efficient to call this method repeatedly for a small number of bits.

Specified by:
nextBits in interface PRNGProvider
Parameters:
bits - the number of random bits requested, which must be greater than or equal to zero
Returns:
a random int less than (1 << bits)

nextInts

void nextInts(int[] array,
              int start,
              int count)
Description copied from interface: PRNGProvider
Fills the given array with random ints, as if nextBits(32) were called for each element.

Specified by:
nextInts in interface PRNGProvider
Parameters:
array - the array to fill
start - the starting index to fill
count - the number of elements to fill, which must be greater than or equal to zero

nextBoolean

boolean nextBoolean()
Returns the next pseudorandom, uniformly distributed boolean value from the generator's sequence.

Returns:
a boolean

nextBoolean

boolean nextBoolean(float probability)
Returns a pseudorandom boolean value from the generator's sequence with the given probability that it will be true.

Parameters:
probability - a float between 0 and 1 (inclusive)
Returns:
a boolean

nextBoolean

boolean nextBoolean(double probability)
Returns a pseudorandom boolean value from the generator's sequence with the given probability that it will be true.

Parameters:
probability - a double between 0 and 1 (inclusive)
Returns:
a boolean

nextInt

int nextInt()
Returns the next pseudorandom, uniformly distributed int value from the generator's sequence.

Returns:
an int

nextInt

int nextInt(int limit)
Returns the next pseudorandom, uniformly distributed, positive int value between 0 (inclusive) and limit (exclusive) from the generator's sequence.

Parameters:
limit - an int greater than 0 that the generated int must be less than
Returns:
an int between 0 (inclusive) and limit (exclusive)

nextInt

int nextInt(int min,
            int max)
Returns the next pseudorandom, uniformly distributed int value between min and max (inclusive) from the generator's sequence.

Parameters:
min - the minimum value to return
max - the maximum value to return
Returns:
an int between min and max (inclusive)

nextLong

long nextLong()
Returns the next pseudorandom, uniformly distributed long value from the generator's sequence.

Returns:
a long

nextFloat

float nextFloat()
Returns the next pseudorandom, uniformly distributed float value between 0.0 and 1.0 from the generator's sequence.

Returns:
a float

nextDouble

double nextDouble()
Returns the next pseudorandom, uniformly distributed double value between 0.0 and 1.0 from the generator's sequence.

Returns:
a double

nextBitVector

BitVector nextBitVector(int numBits)
Returns the next pseudorandom, uniformly distributed BitVector value between 0 and 2numBits.

Parameters:
numBits - the length of the BitVector to be returned, which must be greater than 0
Returns:
a BitVector
Throws:
IllegalArgumentException - if numBits <= 0.

clone

PRNG clone()
Returns a new instance of this PRNG with the same state, meaning that each instance will independently generate the same sequence.

Specified by:
clone in interface PRNGProvider
Returns:
a clone of this PRNG