Package org.ujmp.core.util
Class MathUtil
java.lang.Object
org.ujmp.core.util.MathUtil
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final double[]
private static List<DateFormat>
static final double
static final double
static final double
private static final Random
private static final ThreadLocal<Random>
static final double
private static long
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic final double
static final double
artanh
(double x) static final long
binomialCoefficient
(int n, int k) static final BigInteger
binomialCoefficientBig
(int n, int k) static final double[]
collectionToDoubleArray
(Collection<? extends Number> numbers) static final int[]
collectionToIntArray
(Collection<? extends Number> numbers) static final long[]
collectionToLongArray
(Collection<? extends Number> numbers) static final BigDecimal
divide
(BigDecimal v1, BigDecimal v2) static boolean
static double
f1Measure
(double precision, double recall) static double
f1Measure
(double tp, double fp, double fn) static double
static double
f1MeasureMacro
(Matrix confusionMatrix) static double
f1MeasureMicro
(Matrix confusionMatrix) static final long
factorial
(int n) static final BigInteger
factorialBig
(int n) static double
fallout
(double tn, double fp) static double
falseNegativeRate
(double fn, double tp) static double
falsePositiveRate
(double fp, double tn) static double
fBetaMeasure
(double beta, double precision, double recall) static final double
gammaln
(double x) from numerical recipes in c (p.static final double
gauss
(double mean, double sigma, double x) static BigDecimal
static BigInteger
static boolean
getBoolean
(Object o) static byte
static char
static final Date
static final double
static float
static int
static long
static final Matrix
static Object
static Object
static Random
static final long
getSeed()
static short
static final boolean
greater
(BigInteger i1, BigInteger i2) static String
guid()
static int
hash
(int h) static int
static final double
hypot
(double a, double b) sqrt(a^2 + b^2) without under/overflow.static final double
ignoreNaN
(double v) static final long[]
index2PosColumnMajor
(long[] size, long index) static final long[]
index2PosRowMajor
(long[] size, long index) static String
intToHex
(int i) static boolean
isDigit
(char c) static boolean
isDiscrete
(double number) static boolean
isEventHappening
(double probability) static boolean
isGreater
(BigDecimal v1, BigDecimal v2) static final boolean
isNaNOrInfinite
(double v) static final boolean
static boolean
static boolean
isSign
(char c) static boolean
isSmaller
(BigDecimal v1, BigDecimal v2) static final double
log10
(double d) static final double
log2
(double d) static double[]
logToProbs
(double[] logs) static final int
longToInt
(long value) static final int
longToIntClip
(long value) static double
max
(double[] values) static int
max
(int[] values) static String
md5
(byte[] data) static String
static String
md5
(Serializable o) static String
static int
min
(int[] values) static double[]
minus
(double[] values, double value) static final BigDecimal
minus
(BigDecimal v1, BigDecimal v2) static double
negativePredictiveValue
(double tn, double fn) static boolean
static double
static final double
nextDouble
(double min, double max) static final double
static final double
nextGaussian
(double mean, double sigma) static final int
nextInteger
(int max) static final int
nextInteger
(int min, int max) Returns a random value in the desired intervalstatic double
norminv
(double p, double mu, double sigma) static double[]
plus
(double[] values, double value) static final BigDecimal
plus
(BigDecimal v1, BigDecimal v2) static final long
pos2IndexColumnMajor
(long[] size, long[] pos) static final long
pos2IndexRowMajor
(long[] size, long[] pos) static double
positivePredictiveValue
(double tp, double fp) static double
precision
(double tp, double fp) static double
static double
precisionMacro
(Matrix confusionMatrix) static double
precisionMicro
(Matrix confusionMatrix) randPermInt
(int startInclusive, int endExclusive) randPermLong
(long startInclusive, long endExclusive) static double
recall
(double tp, double fn) static double
static double
recallMacro
(Matrix confusionMatrix) static double
recallMicro
(Matrix confusionMatrix) static final double
round
(double value, int decimals) static final int
search
(long[] values, int fromIndex, int toIndex, long key) static double
sensitivity
(double tp, double fn) static double[]
sequenceDouble
(double startInclusive, double endExclusive) static double[]
sequenceDouble
(double startInclusive, double endExclusive, double stepsize) static int[]
sequenceInt
(int startInclusive, int endExclusive) sequenceListDouble
(double startInclusive, double endExclusive) sequenceListDouble
(double startInclusive, double endExclusive, double stepsize) sequenceListInt
(int startInclusive, int endExclusive) sequenceListLong
(long startInclusive, long endExclusive) sequenceListLong
(long startInclusive, long endExclusive, long stepsize) static long[]
sequenceLong
(long startInclusive, long endExclusive) static long[]
sequenceLong
(long startInclusive, long endExclusive, long stepsize) static void
setSeed
(long seed) static final boolean
smaller
(BigInteger i1, BigInteger i2) static double
specificity
(double tn, double fp) static final BigDecimal
sqrt
(BigDecimal n) static final BigDecimal
times
(BigDecimal v1, BigDecimal v2) static double[]
toDoubleArray
(int... intArray) static double[][]
toDoubleArray
(int[]... intArray) toDoubleList
(double[] numbers) toDoubleList
(int[] numbers) toDoubleList
(long[] numbers) static int[]
toIntArray
(long... coordinates) static long[]
toLongArray
(int... coordinates) toLongList
(int[] numbers) toLongList
(long[] numbers) static final long
totalCorrect
(Matrix confusionMatrix) static double
trueNegativeRate
(double tn, double fp) static final boolean
xor
(boolean b1, boolean b2)
-
Field Details
-
dateFormats
-
EPSILON
public static final double EPSILON- See Also:
-
ROOT2PI
public static final double ROOT2PI -
LOG10
public static final double LOG10 -
LOG2
public static final double LOG2 -
COFGAMMALN
private static final double[] COFGAMMALN -
seed
private static long seed -
randoms
-
random
-
-
Constructor Details
-
MathUtil
public MathUtil()
-
-
Method Details
-
getRandom
-
md5
- Throws:
NoSuchAlgorithmException
-
search
public static final int search(long[] values, int fromIndex, int toIndex, long key) -
md5
-
md5
- Throws:
NoSuchAlgorithmException
IOException
-
md5
- Throws:
NoSuchAlgorithmException
IOException
-
xor
public static final boolean xor(boolean b1, boolean b2) -
logToProbs
public static double[] logToProbs(double[] logs) -
plus
public static double[] plus(double[] values, double value) -
minus
public static double[] minus(double[] values, double value) -
getSeed
public static final long getSeed() -
round
public static final double round(double value, int decimals) -
setSeed
public static void setSeed(long seed) -
log2
public static final double log2(double d) -
log10
public static final double log10(double d) -
hash
public static int hash(int h) -
gauss
public static final double gauss(double mean, double sigma, double x) -
artanh
public static final double artanh(double x) -
nextGaussian
public static final double nextGaussian(double mean, double sigma) -
nextGaussian
public static final double nextGaussian() -
nextDouble
public static final double nextDouble(double min, double max) -
nextInteger
public static final int nextInteger(int min, int max) Returns a random value in the desired interval- Parameters:
min
- minimum value (inclusive)max
- maximum value (exclusive)- Returns:
- a random value
-
nextInteger
public static final int nextInteger(int max) -
isEventHappening
public static boolean isEventHappening(double probability) -
nextBoolean
public static boolean nextBoolean() -
nextDouble
public static double nextDouble() -
ignoreNaN
public static final double ignoreNaN(double v) -
isNaNOrInfinite
public static final boolean isNaNOrInfinite(double v) -
isNaNOrInfinite
-
getMatrix
-
getDate
-
getDouble
-
hypot
public static final double hypot(double a, double b) sqrt(a^2 + b^2) without under/overflow. -
collectionToLongArray
-
collectionToDoubleArray
-
collectionToIntArray
-
toLongList
-
toLongList
-
toDoubleList
-
toDoubleList
-
toDoubleList
-
toDoubleArray
public static double[] toDoubleArray(int... intArray) -
toDoubleArray
public static double[][] toDoubleArray(int[]... intArray) -
sequenceListLong
-
sequenceListLong
-
sequenceListDouble
-
sequenceListDouble
-
sequenceListInt
-
sequenceLong
public static long[] sequenceLong(long startInclusive, long endExclusive) -
sequenceLong
public static long[] sequenceLong(long startInclusive, long endExclusive, long stepsize) -
sequenceDouble
public static double[] sequenceDouble(double startInclusive, double endExclusive) -
sequenceDouble
public static double[] sequenceDouble(double startInclusive, double endExclusive, double stepsize) -
sequenceInt
public static int[] sequenceInt(int startInclusive, int endExclusive) -
randPermLong
-
randPermInt
-
equals
-
sensitivity
public static double sensitivity(double tp, double fn) -
specificity
public static double specificity(double tn, double fp) -
positivePredictiveValue
public static double positivePredictiveValue(double tp, double fp) -
negativePredictiveValue
public static double negativePredictiveValue(double tn, double fn) -
falsePositiveRate
public static double falsePositiveRate(double fp, double tn) -
falseNegativeRate
public static double falseNegativeRate(double fn, double tp) -
recall
public static double recall(double tp, double fn) -
precision
public static double precision(double tp, double fp) -
fallout
public static double fallout(double tn, double fp) -
trueNegativeRate
public static double trueNegativeRate(double tn, double fp) -
f1Measure
public static double f1Measure(double precision, double recall) -
fBetaMeasure
public static double fBetaMeasure(double beta, double precision, double recall) -
getPreferredObject
-
getBoolean
-
getByte
-
getBigInteger
-
getBigDecimal
-
getChar
-
getFloat
-
getObject
-
getInt
-
getLong
-
getShort
-
toIntArray
public static int[] toIntArray(long... coordinates) -
toLongArray
public static long[] toLongArray(int... coordinates) -
isNull
-
norminv
public static double norminv(double p, double mu, double sigma) -
f1Measure
public static double f1Measure(double tp, double fp, double fn) -
factorial
public static final long factorial(int n) -
factorialBig
-
binomialCoefficient
public static final long binomialCoefficient(int n, int k) -
binomialCoefficientBig
-
greater
-
smaller
-
max
public static int max(int[] values) -
max
public static double max(double[] values) -
min
public static int min(int[] values) -
plus
-
minus
-
times
-
divide
-
isGreater
-
isSmaller
-
sqrt
-
gammaln
public static final double gammaln(double x) from numerical recipes in c (p. 214) -
pos2IndexRowMajor
public static final long pos2IndexRowMajor(long[] size, long[] pos) -
pos2IndexColumnMajor
public static final long pos2IndexColumnMajor(long[] size, long[] pos) -
index2PosRowMajor
public static final long[] index2PosRowMajor(long[] size, long index) -
index2PosColumnMajor
public static final long[] index2PosColumnMajor(long[] size, long index) -
totalCorrect
-
accuracy
-
precisionMacro
-
recallMacro
-
f1MeasureMacro
-
precision
-
recall
-
f1Measure
-
precisionMicro
-
recallMicro
-
f1MeasureMicro
-
longToIntClip
public static final int longToIntClip(long value) -
longToInt
public static final int longToInt(long value) -
isDigit
public static boolean isDigit(char c) -
isSign
public static boolean isSign(char c) -
hexToInt
-
intToHex
-
isDiscrete
public static boolean isDiscrete(double number) -
guid
-