public class RandomGenerator
extends java.lang.Object
Constructor and Description |
---|
RandomGenerator() |
Modifier and Type | Method and Description |
---|---|
static java.util.Random |
get() |
static void |
main(java.lang.String[] args) |
static double |
nextDouble() |
static double |
nextDouble(double min,
double max) |
static double |
nextGaussian()
Next random number from a normal (Gaussian) distribution
with mean zero and unit standard deviation.
|
static double |
nextGaussian(double mu,
double sigma)
Generates a random number from a normal (Gaussian)
distribution with mean mu and s.d.
|
static int |
nextInt(int n)
Generate a random number between 0 and n-1
|
static int |
nextInt(int min,
int max)
Generate a random number between min and max, inclusive
|
static int[] |
randomSequence(int min,
int max,
int n)
Generates a random non-repeating sequence of
n integers in the
range min , max (inclusive). |
static int[] |
randomSubsequence(int n)
Generates a random subsequence of the integers 0, ...
|
static int[] |
randomSubsequence(int min,
int max)
Generates a random subsequence of the integers in the range
{@code min, ...
|
static double[] |
randomUnityPartition(int n)
Generates a random sequence of
n numbers that sum to 1. |
static void |
set(java.util.Random generator) |
static void |
setSeed(int seed) |
public static java.util.Random get()
public static void set(java.util.Random generator)
public static void setSeed(int seed)
public static double nextDouble(double min, double max)
public static double nextDouble()
public static double nextGaussian()
public static double nextGaussian(double mu, double sigma)
mu
- meansigma
- standard deviationpublic static int nextInt(int min, int max)
min
- minimum valuemax
- maximum valuepublic static int nextInt(int n)
n
- upper limitpublic static int[] randomSubsequence(int n)
n
- size of the subsequencepublic static int[] randomSubsequence(int min, int max)
min, ... max
, inclusive.min
- lowest possible integer in the sequencemax
- highest possible integer in the sequencepublic static int[] randomSequence(int min, int max, int n)
n
integers in the
range min
, max
(inclusive). n
must be
<= r
, where r = max - min + 1
.
Note: this method has a complexity of O(r)
.
min
- minimum sequence valuemax
- maximum sequence valuen
- number of sequence valuespublic static double[] randomUnityPartition(int n)
n
numbers that sum to 1.n
- number of sequence valuespublic static void main(java.lang.String[] args)