java.lang.Object | |
↳ | java.util.Random |
Known Direct Subclasses |
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Constructs a random generator with an initial state that is
unlikely to be duplicated by a subsequent instantiation.
| |||||||||||
Construct a random generator with the given
seed as the
initial state. |
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Returns a pseudo-random uniformly distributed
boolean . | |||||||||||
Fills
buf with random bytes. | |||||||||||
Returns a pseudo-random uniformly distributed
double
in the half-open range [0.0, 1.0). | |||||||||||
Returns a pseudo-random uniformly distributed
float
in the half-open range [0.0, 1.0). | |||||||||||
Returns a pseudo-random (approximately) normally distributed
double with mean 0.0 and standard deviation 1.0. | |||||||||||
Returns a pseudo-random uniformly distributed
int
in the half-open range [0, n). | |||||||||||
Returns a pseudo-random uniformly distributed
int . | |||||||||||
Returns a pseudo-random uniformly distributed
long . | |||||||||||
Modifies the seed using a 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
|
Constructs a random generator with an initial state that is unlikely to be duplicated by a subsequent instantiation.
The initial state (that is, the seed) is partially based on the current time of day in milliseconds.
Construct a random generator with the given seed
as the
initial state. Equivalent to Random r = new Random(); r.setSeed(seed);
.
seed | the seed that will determine the initial state of this random number generator. |
---|
Returns a pseudo-random uniformly distributed boolean
.
Returns a pseudo-random uniformly distributed double
in the half-open range [0.0, 1.0).
Returns a pseudo-random uniformly distributed float
in the half-open range [0.0, 1.0).
Returns a pseudo-random (approximately) normally distributed
double
with mean 0.0 and standard deviation 1.0.
This method uses 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.
Returns a pseudo-random uniformly distributed int
in the half-open range [0, n).
Modifies the seed using a linear congruential formula presented in The Art of Computer Programming, Volume 2, Section 3.2.1.
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.
Most applications will want to use one of this class' convenience methods instead.