public class Random
extends java.lang.Object
| Constructor and Description |
|---|
Random()
Initialize with default random number generator engine.
|
Random(long seed)
Initialize with given seed for default random number generator engine.
|
Random(RandomNumberGenerator rng)
Initialize with given random number generator engine.
|
| Modifier and Type | Method and Description |
|---|---|
double |
nextDouble()
Generator a random number uniformly distributed in [0, 1).
|
double |
nextDouble(double lo,
double hi)
Generate a uniform random number in the range [lo, hi)
|
void |
nextDoubles(double[] d)
Generate n uniform random numbers in the range [0, 1)
|
void |
nextDoubles(double[] d,
double lo,
double hi)
Generate n uniform random numbers in the range [lo, hi)
|
int |
nextInt()
Returns a random integer.
|
int |
nextInt(int n)
Returns a random integer in [0, n).
|
long |
nextLong() |
void |
permutate(double[] x)
Generates a permutation of given array.
|
void |
permutate(float[] x)
Generates a permutation of given array.
|
int[] |
permutate(int n)
Generates a permutation of 0, 1, 2, ..., n-1, which is useful for
sampling without replacement.
|
void |
permutate(int[] x)
Generates a permutation of given array.
|
void |
permutate(java.lang.Object[] x)
Generates a permutation of given array.
|
void |
setSeed(long seed)
Initialize the random generator with a seed.
|
public Random()
public Random(long seed)
public Random(RandomNumberGenerator rng)
public double nextDouble()
public void nextDoubles(double[] d)
d - array of random numbers to be generatedpublic double nextDouble(double lo,
double hi)
lo - lower limit of rangehi - upper limit of rangepublic void nextDoubles(double[] d,
double lo,
double hi)
lo - lower limit of rangehi - upper limit of ranged - array of random numbers to be generatedpublic void setSeed(long seed)
public int nextInt()
public int nextInt(int n)
public long nextLong()
public int[] permutate(int n)
public void permutate(int[] x)
public void permutate(float[] x)
public void permutate(double[] x)
public void permutate(java.lang.Object[] x)