public final class MathUtil
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static class |
MathUtil.LogMath
A collection of common math operations that work with log values.
|
Modifier and Type | Field and Description |
---|---|
static MathUtil.LogMath |
LOG_10_MATH |
static MathUtil.LogMath |
LOG_2_MATH |
static double |
MAX_PROB_BELOW_ONE
The double value closest to 1 while still being less than 1.
|
static MathUtil.LogMath |
NATURAL_LOG_MATH |
Modifier and Type | Method and Description |
---|---|
static int |
compare(int v1,
int v2) |
static double[] |
divide(double[] numerators,
double[] denominators)
Calculates the ratio of two arrays of the same length.
|
static int |
indexOfMax(double[] nums)
Returns the index of the largest element in the array.
|
static int |
indexOfMax(long[] nums)
Returns the index of the largest element in the array.
|
static double |
log10_1p(double x)
this function mimics the behavior of log_1p but resulting in log _base 10_ of (1+x) instead of natural log of 1+x
|
static double[] |
logLikelihoodsToProbs(double[] likelihoods)
Deprecated.
|
static double |
max(double[] nums)
Returns the largest value stored in the array.
|
static long |
max(long[] nums)
Returns the largest value stored in the array.
|
static double |
mean(double[] in,
int start,
int stop)
Calculated the mean of an array of doubles.
|
static double |
median(double... in)
Calculate the median of an array of doubles.
|
static byte |
min(byte[] nums)
Returns the smallest value stored in the array.
|
static double |
min(double[] nums)
Returns the smallest value stored in the array.
|
static int |
min(int[] nums)
Returns the smallest value stored in the array.
|
static short |
min(short[] nums)
Returns the smallest value stored in the array.
|
static double[] |
multiply(double[] lhs,
double[] rhs)
Calculates the product of two arrays of the same length.
|
static java.lang.Double |
percentageOrNull(java.lang.Long numerator,
java.lang.Long denominator)
Obtains percentage of two Longs
|
static double[] |
pNormalizeLogProbability(double[] lPosterior)
Takes a complete set of mutually exclusive logPosteriors and converts them to probabilities
that sum to 1 with as much fidelity as possible.
|
static double[] |
pNormalizeVector(double[] pPosterior)
Takes a vector of numbers and converts it to a vector of probabilities
that sum to 1 with as much fidelity as possible.
|
static double[] |
promote(int[] is)
"Promotes" an int[] into a double array with the same values (or as close as precision allows).
|
static double |
round(double num,
int precision)
Round off the value to the specified precision.
|
static double[] |
seq(double from,
double to,
double by)
Mimic's R's seq() function to produce a sequence of equally spaced numbers.
|
static double |
stddev(double[] in,
int start,
int length)
Calculated the standard deviation of an array of doubles.
|
static double |
stddev(double[] in,
int start,
int stop,
double mean)
Calculated the standard deviation of an array of doubles.
|
static double |
sum(double[] arr)
Returns the sum of the elements in the array.
|
static double[] |
sum(double[] lhs,
double[] rhs)
calculates the sum of the arrays as a third array.
|
static long |
sum(long[] arr,
int start,
int stop)
Returns the sum of the elements in the array starting with start and ending before stop.
|
public static final double MAX_PROB_BELOW_ONE
public static final MathUtil.LogMath LOG_2_MATH
public static final MathUtil.LogMath NATURAL_LOG_MATH
public static final MathUtil.LogMath LOG_10_MATH
public static double log10_1p(double x)
public static double mean(double[] in, int start, int stop)
public static double stddev(double[] in, int start, int length)
public static double stddev(double[] in, int start, int stop, double mean)
public static int compare(int v1, int v2)
public static double median(double... in)
public static java.lang.Double percentageOrNull(java.lang.Long numerator, java.lang.Long denominator)
numerator
- dividenddenominator
- divisorpublic static double round(double num, int precision)
public static double max(double[] nums)
public static int indexOfMax(double[] nums)
public static long max(long[] nums)
public static int indexOfMax(long[] nums)
public static double min(double[] nums)
public static int min(int[] nums)
public static short min(short[] nums)
public static byte min(byte[] nums)
public static double[] seq(double from, double to, double by)
public static double[] promote(int[] is)
@Deprecated public static double[] logLikelihoodsToProbs(double[] likelihoods)
public static double[] pNormalizeLogProbability(double[] lPosterior)
public static double[] divide(double[] numerators, double[] denominators)
public static double[] pNormalizeVector(double[] pPosterior)
public static double[] multiply(double[] lhs, double[] rhs)
public static double[] sum(double[] lhs, double[] rhs)
public static double sum(double[] arr)
public static long sum(long[] arr, int start, int stop)