RandomGenerator interface.
Default implementations for all methods other than nextDouble() and
setSeed(long) are provided.
All data generation methods are based on code nextDouble().
Concrete implementations must override
this method and should provide better / more
performant implementations of the other methods if the underlying PRNG
supplies them.
| Modifier and Type | Field and Description |
|---|---|
| private double | cachedNormalDeviate
Cached random normal value. |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public void | |
| public boolean | Returns: the next pseudorandom, uniformly distributedboolean value from this random number generator's
sequenceImplements org. Returns the next pseudorandom, uniformly distributed
|
| public void | nextBytes(byte[]
the non-null byte array in which to put the
random bytes bytes)Implements org. Generates random bytes and places them into a user-supplied byte array. |
| public abstract double | Returns: the next pseudorandom, uniformly distributeddouble value between 0.0 and
1.0 from this random number generator's sequenceRedeclares org. Returns the next pseudorandom, uniformly distributed
|
| public float | Returns: the next pseudorandom, uniformly distributedfloat
value between 0.0 and 1.0 from this
random number generator's sequenceImplements org. Returns the next pseudorandom, uniformly distributed |
| public double | Returns: the next pseudorandom, Gaussian ("normally") distributeddouble value with mean 0.0 and
standard deviation 1.0 from this random number
generator's sequenceImplements org. Returns the next pseudorandom, Gaussian ("normally") distributed
|
| public int | Returns: the next pseudorandom, uniformly distributedint
value from this random number generator's sequenceImplements org. Returns the next pseudorandom, uniformly distributed |
| public int | Returns: a pseudorandom, uniformly distributedint
value between 0 (inclusive) and n (exclusive).the bound on the random number to be returned. Must be
positive. n)Implements org. Returns a pseudorandom, uniformly distributed |
| public long | Returns: the next pseudorandom, uniformly distributedlong
value from this random number generator's sequenceImplements org. Returns the next pseudorandom, uniformly distributed |
| public void | setSeed(int
the seed value seed)Implements org. Sets the seed of the underlying random number generator using an
|
| public void | setSeed(int[]
the seed value seed)Implements org. Sets the seed of the underlying random number generator using an
|
| public abstract void | setSeed(long
the seed value seed)Redeclares org. Sets the seed of the underlying random number generator using a
|
| cachedNormalDeviate | back to summary |
|---|---|
| private double cachedNormalDeviate Cached random normal value. The default implementation for
| |
| AbstractRandomGenerator | back to summary |
|---|---|
| public AbstractRandomGenerator() Construct a RandomGenerator. | |
| clear | back to summary |
|---|---|
| public void clear() Clears the cache used by the default implementation of
| |
| nextBoolean | back to summary |
|---|---|
| public boolean nextBoolean() Implements org. Returns the next pseudorandom, uniformly distributed
The default implementation returns
| |
| nextBytes | back to summary |
|---|---|
| public void nextBytes(byte[] bytes) Implements org. Generates random bytes and places them into a user-supplied byte array. The number of random bytes produced is equal to the length of the byte array.
The default implementation fills the array with bytes extracted from
random integers generated using
| |
| nextDouble | back to summary |
|---|---|
| public abstract double nextDouble() Redeclares org. Returns the next pseudorandom, uniformly distributed
This method provides the underlying source of random data used by the other methods.
| |
| nextFloat | back to summary |
|---|---|
| public float nextFloat() Implements org. Returns the next pseudorandom, uniformly distributed The default implementation returns
| |
| nextGaussian | back to summary |
|---|---|
| public double nextGaussian() Implements org. Returns the next pseudorandom, Gaussian ("normally") distributed
The default implementation uses the Polar Method due to G.E.P. Box, M.E. Muller and G. Marsaglia, as described in D. Knuth, The Art of Computer Programming, 3.4.1C.
The algorithm generates a pair of independent random values. One of
these is cached for reuse, so the full algorithm is not executed on each
activation. Implementations that do not override this method should
make sure to call
| |
| nextInt | back to summary |
|---|---|
| public int nextInt() Implements org. Returns the next pseudorandom, uniformly distributed The default implementation provided here returns
| |
| nextInt | back to summary |
|---|---|
| public int nextInt(int n) Implements org. Returns a pseudorandom, uniformly distributed The default implementation returns
| |
| nextLong | back to summary |
|---|---|
| public long nextLong() Implements org. Returns the next pseudorandom, uniformly distributed The default implementation returns
| |
| setSeed | back to summary |
|---|---|
| public void setSeed(int seed) Implements org. Doc from org. Sets the seed of the underlying random number generator using an
Sequences of values generated starting with the same seeds should be identical.
| |
| setSeed | back to summary |
|---|---|
| public void setSeed(int[] seed) Implements org. Doc from org. Sets the seed of the underlying random number generator using an
Sequences of values generated starting with the same seeds should be identical.
| |
| setSeed | back to summary |
|---|---|
| public abstract void setSeed(long seed) Redeclares org. Sets the seed of the underlying random number generator using a
Implementations that do not override the default implementation of
| |