public class MoreMath
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static double |
LOG_2
Precomputed ln(2).
|
Constructor and Description |
---|
MoreMath() |
Modifier and Type | Method and Description |
---|---|
static boolean |
areProbabilities(double[] d)
Calls
areProbabilities(double[], double) with a default TOLERANCE of 0. |
static boolean |
areProbabilities(double[] d,
double TOLERANCE)
Returns true iff each value in d is a probability in the range [0..1] and teh sum of the values of d are within TOLERANCE of 1.0.
|
static java.lang.String |
getUsedMemory() |
static boolean |
isProbability(double d)
Calls
areProbabilities(double[], double) with a default TOLERANCE of 0. |
static boolean |
isProbability(double d,
double TOLERANCE)
Returns true iff d is in the range [0..1] allowing for the given TOLERANCE.
|
static double |
logFactorial(int n)
Computes and returns ln(n!).
|
static double |
logLikelihood(double average,
double observed)
Returns the log likelihood ratio, definied as log_2[observed / average].
|
static boolean |
randomBool(double p)
Returns a random boolean, where p is the probability that true is returned.
|
static int |
randomInt(int min,
int max)
Returns a random integer in the range [min..max).
|
static double |
sign(double d)
Returns -1, 0, or 1 as d is negative, zero, or positive.
|
public static boolean areProbabilities(double[] d)
areProbabilities(double[], double)
with a default TOLERANCE of 0.public static boolean areProbabilities(double[] d, double TOLERANCE)
public static java.lang.String getUsedMemory()
public static boolean isProbability(double d)
areProbabilities(double[], double)
with a default TOLERANCE of 0.public static boolean isProbability(double d, double TOLERANCE)
public static double logFactorial(int n)
public static double logLikelihood(double average, double observed)
public static boolean randomBool(double p)
public static int randomInt(int min, int max)
public static double sign(double d)