@TestClass(value="org.openscience.cdk.math.RandomNumbersToolTest") 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. |
nextBoolean, nextBytes, nextDouble, nextFloat, nextGaussian, nextInt, nextInt, nextLong, setSeed
@TestMethod(value="testSetRandom") public static void setRandom(Random base_random)
base_random
- a java.util.Random
subclass.@TestMethod(value="testSetRandomSeed_long") public static void setRandomSeed(long new_seed)
long
seed.new_seed
- the seed to be used by the random number generator.@TestMethod(value="testGetRandomSeed") public static long getRandomSeed()
long
seed.@TestMethod(value="testSetRandom") public static Random getRandom()
@TestMethod(value="testRandomInt") public static int randomInt()
0
and 1
.
0
and 1
.@TestMethod(value="testRandomInt_int_int") 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
.@TestMethod(value="testRandomLong") public static long randomLong()
0
and 1
.
0
and 1
.@TestMethod(value="testRandomLong_long_long") 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
.@TestMethod(value="testRandomFloat") public static float randomFloat()
0
and 1
.
0
and 1
.@TestMethod(value="testRandomFloat_float_float") 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
.@TestMethod(value="testRandomDouble") public static double randomDouble()
0
and 1
.
0
and 1
.@TestMethod(value="testRandomDouble_double_double") 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
.@TestMethod(value="testRandomBoolean") public static boolean randomBoolean()
@TestMethod(value="testRandomBit") public static int randomBit()
0
or 1
.
@TestMethod(value="testFlipCoin") public static boolean flipCoin(double p)
p
- the probability of success.true
if a success was found; false
otherwise.@TestMethod(value="testGaussianFloat") public static float gaussianFloat(float dev)
dev
- the desired deviation.dev
.@TestMethod(value="testGaussianDouble") public static double gaussianDouble(double dev)
dev
- the desired deviation.dev
.@TestMethod(value="testExponentialDouble") public static double exponentialDouble(double mean)
mean
- the desired mean value.mean
.