java.lang.Object | |
↳ | java.util.Random |
Known Direct Subclasses |
This class provides methods that generates pseudo-random numbers of different
types, such as int
, long
, double
, and float
.
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Construct a random generator with the current time of day in milliseconds
as the initial state.
| |||||||||||
Construct a random generator with the given
seed as the
initial state. |
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Returns the next pseudo-random, uniformly distributed
boolean value
generated by this generator. | |||||||||||
Modifies the
byte array by a random sequence of byte s generated by this
random number generator. | |||||||||||
Generates a normally distributed random
double number between 0.0
inclusively and 1.0 exclusively. | |||||||||||
Generates a normally distributed random
float number between 0.0
inclusively and 1.0 exclusively. | |||||||||||
Pseudo-randomly generates (approximately) a normally distributed
double value with mean 0.0 and a standard deviation value
of 1.0 using the polar method of G. | |||||||||||
Returns a new pseudo-random
int value which is uniformly distributed
between 0 (inclusively) and the value of n (exclusively). | |||||||||||
Generates a uniformly distributed 32-bit
int value from
the random number sequence. | |||||||||||
Generates a uniformly distributed 64-bit integer value from
the random number sequence.
| |||||||||||
Modifies the seed a using linear congruential formula presented in The
Art of Computer Programming, Volume 2, Section 3.2.1.
|
Protected Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Returns a pseudo-random uniformly distributed
int value of
the number of bits specified by the argument bits as
described by Donald E. |
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class java.lang.Object
|
Construct a random generator with the current time of day in milliseconds as the initial state.
Construct a random generator with the given seed
as the
initial state.
seed | the seed that will determine the initial state of this random number generator. |
---|
Returns the next pseudo-random, uniformly distributed boolean
value
generated by this generator.
Modifies the byte
array by a random sequence of byte
s generated by this
random number generator.
buf | non-null array to contain the new random byte s. |
---|
Generates a normally distributed random double
number between 0.0
inclusively and 1.0 exclusively.
double
in the range [0.0 - 1.0)Generates a normally distributed random float
number between 0.0
inclusively and 1.0 exclusively.
float
number between [0.0 and 1.0)Pseudo-randomly generates (approximately) a normally distributed
double
value with mean 0.0 and a standard deviation value
of 1.0
using the polar method of G. E. P. Box, M.
E. Muller, and G. Marsaglia, as described by Donald E. Knuth in The
Art of Computer Programming, Volume 2: Seminumerical Algorithms,
section 3.4.1, subsection C, algorithm P.
double
Returns a new pseudo-random int
value which is uniformly distributed
between 0 (inclusively) and the value of n
(exclusively).
n | the exclusive upper border of the range [0 - n). |
---|
int
.
Generates a uniformly distributed 32-bit int
value from
the random number sequence.
int
value.Generates a uniformly distributed 64-bit integer value from the random number sequence.
Modifies the seed a using linear congruential formula presented in The Art of Computer Programming, Volume 2, Section 3.2.1.
seed | the seed that alters the state of the random number generator. |
---|
Returns a pseudo-random uniformly distributed int
value of
the number of bits specified by the argument bits
as
described by Donald E. Knuth in The Art of Computer Programming,
Volume 2: Seminumerical Algorithms, section 3.2.1.
bits | number of bits of the returned value. |
---|