|
Build 1.0_r1(from source) | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjava.util.Random
public class Random
This class provides methods that generates pseudo-random numbers of different types, such as int, long, double and float using either
Properties,
PropertyResourceBundle,
Serialized Form| Field Summary | |
|---|---|
(package private) boolean |
haveNextNextGaussian
The boolean value indicating if the second Gaussian number is available. |
(package private) static long |
multiplier
|
(package private) double |
nextNextGaussian
The second Gaussian generated number. |
(package private) long |
seed
|
| Constructor Summary | |
|---|---|
Random()
Construct a random generator with the current time of day in milliseconds as the initial state. |
|
Random(long seed)
Construct a random generator with the given seed as the
initial state. |
|
| Method Summary | |
|---|---|
protected int |
next(int bits)
Returns a pseudo-random uniformly distributed int value of
the number of bits specified by the argument bits as
described by Donald E. |
boolean |
nextBoolean()
Returns the next pseudo-random, uniformly distributed boolean value generated by this generator. |
void |
nextBytes(byte[] buf)
Modifies the byte array by a random sequence of bytes generated by this random number generator. |
double |
nextDouble()
Generates a normally distributed random double number between 0.0 inclusively and 1.0 exclusively. |
float |
nextFloat()
Generates a normally distributed random float number between 0.0 inclusively and 1.0 exclusively. |
double |
nextGaussian()
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. |
int |
nextInt()
Generates a uniformly distributed 32-bit int value from
the this random number sequence. |
int |
nextInt(int n)
Returns to the caller a new pseudo-random integer value which is uniformly distributed between 0 (inclusively) and the value of n
(exclusively). |
long |
nextLong()
Generates a uniformly distributed 64-bit int value from
the this random number sequence. |
void |
setSeed(long seed)
Modifies the seed using linear congruential formula presented in The Art of Computer Programming, Volume 2, Section 3.2.1. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
static final long multiplier
boolean haveNextNextGaussian
long seed
double nextNextGaussian
| Constructor Detail |
|---|
public Random()
setSeed(long)public Random(long seed)
seed as the
initial state.
seed - the seed that will determine the initial state of this random
number generatorsetSeed(long)| Method Detail |
|---|
protected int next(int bits)
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
nextBytes(byte[]),
nextDouble(),
nextFloat(),
nextInt(),
nextInt(int),
nextGaussian(),
nextLong()public boolean nextBoolean()
public void nextBytes(byte[] buf)
buf - non-null array to contain the new random bytesnext(int)public double nextDouble()
nextFloat()public float nextFloat()
nextDouble()public double nextGaussian()
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
nextDouble()public int nextInt()
int value from
the this random number sequence.
int valueInteger.MAX_VALUE,
Integer.MIN_VALUE,
next(int),
nextLong()public int nextInt(int n)
n
(exclusively).
n - int
public long nextLong()
int value from
the this random number sequence.
int random numberInteger.MAX_VALUE,
Integer.MIN_VALUE,
next(int),
nextInt(),
nextInt(int)public void setSeed(long seed)
seed - the seed that alters the state of the random number generatornext(int),
Random(),
Random(long)
|
Build 1.0_r1(from source) | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||