public final class RandomUtils extends Object
Modifier and Type | Method and Description |
---|---|
static boolean |
getBoolean(Random random,
double probability)
Returns a boolean being true with the given probability.
|
static double |
getNormalDouble(Random random,
double min,
double max,
double mean,
double variance)
Returns a normally distributed random double within min and max (both inclusive), having the specified mean and the specified variance.
|
static int |
getNormalInteger(Random random,
int min,
int max,
double mean,
double variance)
Returns a normally distributed random integer within min and max (both inclusive), having the specified mean and the specified variance.
|
static double |
getPowerDouble(double value,
double min,
double max,
double exponent)
Converts the given random value (between 0 and 1) into a double with a power distribution of the given exponent between min (inclusive) and max
(exclusive).
|
static double |
getPowerDouble(Random random,
double min,
double max,
double exponent)
Returns a random double with a power distribution of the given exponent between min (inclusive) and max (exclusive).
|
static double |
getUniformDouble(Random random,
double min,
double max)
Returns a random double uniformly distributed within min (inclusive) and max (exclusive). max cannot be returned by this method, but even if it
could, the probability for the random value being exactly max would be negligible (in the order of 2^-53).
|
static double |
getUniformDouble(Random random,
double min,
double max,
double step)
Returns a random double uniformly distributed within min (inclusive) and max (exclusive), using a granularity of step.
|
static int |
getUniformInteger(Random random,
int min,
int max,
int step)
Returns a random integer uniformly distributed within min and max (both inclusive), using a granularity of step.
|
public static int getUniformInteger(Random random, int min, int max, int step)
random
- the random generatormin
- the minimum value (inclusive)max
- the maximum value (inclusive)step
- the step (must be >= 0)public static double getUniformDouble(Random random, double min, double max)
random
- the random generatormin
- the minimum value (inclusive)max
- the maximum value (exclusive)public static double getUniformDouble(Random random, double min, double max, double step)
random
- the random generatormin
- the minimum value (inclusive)max
- the maximum value (exclusive)step
- the step (must be >= 0)public static int getNormalInteger(Random random, int min, int max, double mean, double variance)
random
- the random generatormin
- the minimum value (inclusive)max
- the maximum value (inclusive)mean
- the mean valuevariance
- the variance (square of the standard deviation)public static double getNormalDouble(Random random, double min, double max, double mean, double variance)
random
- the random generatormin
- the minimum value (inclusive)max
- the maximum value (inclusive)mean
- the mean valuevariance
- the variance (square of the standard deviation)public static double getPowerDouble(Random random, double min, double max, double exponent)
random
- the random generatormin
- the minimum value (inclusive)max
- the maximum value (exclusive)exponent
- the exponent (1 = linear, 2 = quadratic, 3 = cubic, -1 = reverse linear, etc.)public static double getPowerDouble(double value, double min, double max, double exponent)
value
- the random value (between 0 and 1)min
- the minimum value (inclusive)max
- the maximum value (exclusive)exponent
- the exponent (1 = linear, 2 = quadratic, 3 = cubic, -1 = reverse linear, etc.)public static boolean getBoolean(Random random, double probability)
random
- the random generatorprobability
- the probability (between 0 and 1)