Generate a new double
Generate a new float
Generate a new Gaussian (normally distributed) number
Generate a new Gaussian (normally distributed) number
This is based on Apache Commons Math's nextGaussian, which in turn is based on the Polar Method of Box, Muller, & Marsiglia as described in Knuth 3.4.1C
Generate a new integer
Generate a new long
Generate a new non-negative double
Generate a new non-negative double
Generate a new non-negative float
Generate a new non-negative float
Generate a new non-negative integer
Generate a new non-negative integer
Generate a new non-negative long
Generate a new non-negative long
The Random class provides methods to generate pseudorandom numbers via Marsaglia Xorshift PRNGs, which use simple exclusive-or and bit-shift operations to generate these numbers extremely quickly over long cycles.
For instance, nextInt and nextFloat have cycles of length 232 - 1, while nextLong and nextDouble have cycles of length 264 - 1.
There are 648 possible Marsiglia PRNG choices for 32 bits, and 2200 choices for 64 bits, corresponding to which triples are utilized in the calculations. One triple is chosen at random via a call to java.util.Random for cycling through the 32-bit state, and similarly one for the 64-bit state.
By default, the 64-bit seed is chosen via System.nanoTime, and the 32-bit seed by taking the 32 lower-order bits of the same seed.
To create repeatable behavior, seed0 and seed1 may be specified.
See Marsiglia for details.