Produce an endless stream of Doubles via an iterator
Produce an endless stream of Doubles via an iterator
Produce an endless stream of Floats via an iterator
Produce an endless stream of Floats via an iterator
Produce an endless stream of Ints via an iterator
Produce an endless stream of Ints via an iterator
Produce an endless stream of Longs via an iterator
Produce an endless stream of Longs via an iterator
Return the next Double in the stream.
Return the next Double in the stream. Uses two ints to generate 53 random bits. Symmetric, but due to missing zero a small number of values are ~3% underrepresented.
Return the next Float in the range [0,1) from this random number stream.
Return the next Float in the range [0,1) from this random number stream. Values are equally spaced. Based on nextInt shifted down to 24 bits.
Return the next Int in the stream.
Return the next Int in the stream. 0 cannot be generated, so 1 is subtracted to recover it. (Thus, -1 cannot be generated.)
Return the next Long in the stream.
Return the next Long in the stream. Better to use Marsaglia64x3 if you need Longs--this requires three Ints to avoid weird glitches due to lack-of-zero.
Sets this random number generator to its default initial state.
Sets this random number generator to its default initial state.
Produce a number in {0, 1, .
Produce a number in {0, 1, ..., n-1}
Produce an endless stream of numbers each drawn from {0, 1, .
Produce an endless stream of numbers each drawn from {0, 1, ..., n-1} via an iterator
Load stored state into the generator.
Load stored state into the generator. The convention is that extra bytes are ignored, and a best-effort attempt is made to use overly short arrays to perform partial initialization.
Set the state to i.
Set the state to i. Zero is a degenerate value, so it is promoted to 1.
Seed the generator with the current time.
Seed the generator with the current time. Sequential calls from the same thread produce different seeds.
Store the current state of the generator in an array of bytes.
Store the current state of the generator in an array of bytes.
The current state packed in an Int
The current state packed in an Int
George Marsaglia XorShift RNG with 32 bits of state and 3 shifts. From http://www.jstatsoft.org/v08/i14/paper. Very fast and reasonably random for 32 bits of state, but intrinsically cannot generate 0.