public class RandomNumbersTool extends Random
Constructor and Description |
---|
RandomNumbersTool() |
Modifier and Type | Method and Description |
---|---|
static double |
exponentialDouble(double mean)
Generates a random double from an Exponential distribution with the specified
mean value.
|
static boolean |
flipCoin(double p)
Returns a boolean value based on a biased coin toss.
|
static double |
gaussianDouble(double dev)
Generates a random double from a Gaussian distribution with the specified
deviation.
|
static float |
gaussianFloat(float dev)
Generates a random float from a Gaussian distribution with the specified
deviation.
|
static Random |
getRandom()
Returns the instance of Random used by this class.
|
static long |
getRandomSeed()
Returns the seed being used by this random number generator.
|
static int |
randomBit()
Generates a random bit: either
0 or 1 . |
static boolean |
randomBoolean()
Generates a random boolean.
|
static double |
randomDouble()
Generates a random double between
0 and 1 . |
static double |
randomDouble(double lo,
double hi)
Generates a random double between the specified values.
|
static float |
randomFloat()
Generates a random float between
0 and 1 . |
static float |
randomFloat(float lo,
float hi)
Generates a random float between the specified values.
|
static int |
randomInt()
Generates a random integer between
0 and 1 . |
static int |
randomInt(int lo,
int hi)
Generates a random integer between the specified values.
|
static long |
randomLong()
Generates a random long between
0 and 1 . |
static long |
randomLong(long lo,
long hi)
Generates a random long between the specified values.
|
static void |
setRandom(Random base_random)
Sets the base generator to be used by this class.
|
static void |
setRandomSeed(long new_seed)
Sets the seed of this random number generator using a single
long seed. |
public static void setRandom(Random base_random)
base_random
- a java.util.Random
subclass.public static void setRandomSeed(long new_seed)
long
seed.new_seed
- the seed to be used by the random number generator.public static long getRandomSeed()
long
seed.public static Random getRandom()
public static int randomInt()
0
and 1
.0
and 1
.public static int randomInt(int lo, int hi)
lo
- the lower bound for the generated integer.hi
- the upper bound for the generated integer.lo
and hi
.public static long randomLong()
0
and 1
.0
and 1
.public static long randomLong(long lo, long hi)
lo
- the lower bound for the generated long.hi
- the upper bound for the generated long.lo
and hi
.public static float randomFloat()
0
and 1
.0
and 1
.public static float randomFloat(float lo, float hi)
lo
- the lower bound for the generated float.hi
- the upper bound for the generated float.lo
and hi
.public static double randomDouble()
0
and 1
.0
and 1
.public static double randomDouble(double lo, double hi)
lo
- the lower bound for the generated double.hi
- the upper bound for the generated double.lo
and hi
.public static boolean randomBoolean()
public static int randomBit()
0
or 1
.public static boolean flipCoin(double p)
p
- the probability of success.true
if a success was found; false
otherwise.public static float gaussianFloat(float dev)
dev
- the desired deviation.dev
.public static double gaussianDouble(double dev)
dev
- the desired deviation.dev
.public static double exponentialDouble(double mean)
mean
- the desired mean value.mean
.Copyright © 2022. All rights reserved.