org.ujmp.core.util
Class MathUtil
java.lang.Object
org.ujmp.core.util.MathUtil
public abstract class MathUtil
- extends Object
Method Summary |
static double |
artanh(double x)
|
static long |
binomialCoefficient(int n,
int k)
|
static BigInteger |
binomialCoefficientBig(int n,
int k)
|
static double[] |
collectionToDouble(Collection<? extends Number> numbers)
|
static int[] |
collectionToInt(Collection<? extends Number> numbers)
|
static long[] |
collectionToLong(Collection<? extends Number> numbers)
|
static BigDecimal |
divide(BigDecimal v1,
BigDecimal v2)
|
static boolean |
equals(Object o1,
Object o2)
|
static double |
f1Measure(double precision,
double recall)
|
static double |
f1measure(double tp,
double tn,
double fp,
double fn)
|
static long |
factorial(int n)
|
static 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 double |
gammaln(double x)
from numerical recipes in c (p. 214) |
static double |
gauss(double mean,
double sigma,
double x)
|
static BigDecimal |
getBigDecimal(Object o)
|
static BigInteger |
getBigInteger(Object o)
|
static boolean |
getBoolean(Object o)
|
static byte |
getByte(Object o)
|
static char |
getChar(Object o)
|
static Date |
getDate(Object o)
|
static MathContext |
getDefaultMathContext()
|
static double |
getDouble(Object o)
|
static float |
getFloat(Object o)
|
static int |
getInt(Object o)
|
static long |
getLong(Object o)
|
static Matrix |
getMatrix(Object o)
|
static Object |
getObject(Object o)
|
static Object |
getPreferredObject(Object o)
|
static Random |
getRandom()
|
static long |
getSeed()
|
static short |
getShort(Object o)
|
static boolean |
greater(BigInteger i1,
BigInteger i2)
|
static int |
hash(int h)
|
static double |
hypot(double a,
double b)
sqrt(a^2 + b^2) without under/overflow. |
static double |
ignoreNaN(double v)
|
static long[] |
index2PosColumnMajor(long[] size,
long index)
|
static long[] |
index2PosRowMajor(long[] size,
long index)
|
static boolean |
isEqual(BigDecimal v1,
BigDecimal v2)
|
static boolean |
isEventHappening(double probability)
|
static boolean |
isGreater(BigDecimal v1,
BigDecimal v2)
|
static boolean |
isNaNOrInfinite(double v)
|
static boolean |
isNaNOrInfinite(Object o)
|
static boolean |
isNull(Object value)
|
static boolean |
isSmaller(BigDecimal v1,
BigDecimal v2)
|
static double |
log10(double d)
|
static double |
log2(double d)
|
static double[] |
logToProbs(double[] logs)
|
static int |
max(int[] values)
|
static String |
md5(byte[] data)
|
static String |
md5(File file)
|
static String |
md5(Serializable o)
|
static String |
md5(String text)
|
static int |
min(int[] values)
|
static BigDecimal |
minus(BigDecimal v1,
BigDecimal v2)
|
static double |
negativePredictiveValue(double tn,
double fn)
|
static boolean |
nextBoolean()
|
static double |
nextDouble()
|
static double |
nextGaussian(double mean,
double sigma)
|
static int |
nextInteger(int min,
int max)
Returns a random value in the desired interval |
static double |
nextUniform(double min,
double max)
|
static double |
norminv(double p,
double mu,
double sigma)
|
static BigDecimal |
plus(BigDecimal v1,
BigDecimal v2)
|
static long |
pos2IndexColumnMajor(long[] size,
long[] pos)
|
static long |
pos2IndexRowMajor(long[] size,
long[] pos)
|
static double |
positivePredictiveValue(double tp,
double fp)
|
static double |
precision(double tp,
double fp)
|
static List<Long> |
randPerm(long start,
long end)
|
static double |
recall(double tp,
double fn)
|
static double |
round(double value,
int decimals)
|
static double |
sensitivity(double tp,
double fn)
|
static double[] |
sequenceDouble(double start,
double end)
|
static double[] |
sequenceDouble(double start,
double end,
double stepsize)
|
static int[] |
sequenceInt(int start,
int end)
|
static List<Double> |
sequenceListDouble(double start,
double end)
|
static List<Double> |
sequenceListDouble(double start,
double end,
double stepsize)
|
static List<Integer> |
sequenceListInt(int start,
int end)
|
static List<Long> |
sequenceListLong(long start,
long end)
|
static List<Long> |
sequenceListLong(long start,
long end,
long stepsize)
|
static long[] |
sequenceLong(long start,
long end)
|
static long[] |
sequenceLong(long start,
long end,
long stepsize)
|
static void |
setSeed(long seed)
|
static boolean |
smaller(BigInteger i1,
BigInteger i2)
|
static double |
specificity(double tn,
double fp)
|
static BigDecimal |
sqrt(BigDecimal n)
|
static BigDecimal |
times(BigDecimal v1,
BigDecimal v2)
|
static double[] |
toDoubleArray(int... intArray)
|
static double[][] |
toDoubleArray(int[]... intArray)
|
static List<Double> |
toDoubleList(double[] numbers)
|
static List<Double> |
toDoubleList(int[] numbers)
|
static List<Double> |
toDoubleList(long[] numbers)
|
static int[] |
toIntArray(long... coordinates)
|
static long[] |
toLongArray(int... coordinates)
|
static List<Long> |
toLongList(int[] numbers)
|
static List<Long> |
toLongList(long[] numbers)
|
static double |
trueNegativeRate(double tn,
double fp)
|
static boolean |
xor(boolean b1,
boolean b2)
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
MathUtil
public MathUtil()
getDefaultMathContext
public static MathContext getDefaultMathContext()
md5
public static String md5(String text)
throws NoSuchAlgorithmException
- Throws:
NoSuchAlgorithmException
md5
public static String md5(byte[] data)
throws NoSuchAlgorithmException
- Throws:
NoSuchAlgorithmException
md5
public static String md5(File file)
throws NoSuchAlgorithmException
- Throws:
NoSuchAlgorithmException
md5
public static String md5(Serializable o)
throws NoSuchAlgorithmException,
IOException
- Throws:
NoSuchAlgorithmException
IOException
getRandom
public static final Random getRandom()
xor
public static final boolean xor(boolean b1,
boolean b2)
logToProbs
public static double[] logToProbs(double[] logs)
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)
nextUniform
public static final double nextUniform(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 (inclusive)
- Returns:
- a random value
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
public static final boolean isNaNOrInfinite(Object o)
getMatrix
public static final Matrix getMatrix(Object o)
getDate
public static final Date getDate(Object o)
getDouble
public static final double getDouble(Object o)
hypot
public static final double hypot(double a,
double b)
- sqrt(a^2 + b^2) without under/overflow.
collectionToLong
public static long[] collectionToLong(Collection<? extends Number> numbers)
collectionToDouble
public static double[] collectionToDouble(Collection<? extends Number> numbers)
collectionToInt
public static int[] collectionToInt(Collection<? extends Number> numbers)
toLongList
public static List<Long> toLongList(long[] numbers)
toLongList
public static List<Long> toLongList(int[] numbers)
toDoubleList
public static List<Double> toDoubleList(double[] numbers)
toDoubleList
public static List<Double> toDoubleList(int[] numbers)
toDoubleList
public static List<Double> toDoubleList(long[] numbers)
toDoubleArray
public static double[] toDoubleArray(int... intArray)
toDoubleArray
public static double[][] toDoubleArray(int[]... intArray)
sequenceListLong
public static List<Long> sequenceListLong(long start,
long end)
sequenceListLong
public static List<Long> sequenceListLong(long start,
long end,
long stepsize)
sequenceListDouble
public static List<Double> sequenceListDouble(double start,
double end)
sequenceListDouble
public static List<Double> sequenceListDouble(double start,
double end,
double stepsize)
sequenceListInt
public static List<Integer> sequenceListInt(int start,
int end)
sequenceLong
public static long[] sequenceLong(long start,
long end)
sequenceLong
public static long[] sequenceLong(long start,
long end,
long stepsize)
sequenceDouble
public static double[] sequenceDouble(double start,
double end)
sequenceDouble
public static double[] sequenceDouble(double start,
double end,
double stepsize)
sequenceInt
public static int[] sequenceInt(int start,
int end)
randPerm
public static List<Long> randPerm(long start,
long end)
equals
public static boolean equals(Object o1,
Object o2)
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
public static Object getPreferredObject(Object o)
getBoolean
public static boolean getBoolean(Object o)
getByte
public static byte getByte(Object o)
getBigInteger
public static BigInteger getBigInteger(Object o)
getBigDecimal
public static BigDecimal getBigDecimal(Object o)
getChar
public static char getChar(Object o)
getFloat
public static float getFloat(Object o)
getObject
public static Object getObject(Object o)
getInt
public static int getInt(Object o)
getLong
public static long getLong(Object o)
getShort
public static short getShort(Object o)
toIntArray
public static int[] toIntArray(long... coordinates)
toLongArray
public static long[] toLongArray(int... coordinates)
isNull
public static boolean isNull(Object value)
norminv
public static double norminv(double p,
double mu,
double sigma)
f1measure
public static double f1measure(double tp,
double tn,
double fp,
double fn)
factorial
public static final long factorial(int n)
factorialBig
public static final BigInteger factorialBig(int n)
binomialCoefficient
public static final long binomialCoefficient(int n,
int k)
binomialCoefficientBig
public static final BigInteger binomialCoefficientBig(int n,
int k)
greater
public static final boolean greater(BigInteger i1,
BigInteger i2)
smaller
public static final boolean smaller(BigInteger i1,
BigInteger i2)
max
public static int max(int[] values)
min
public static int min(int[] values)
plus
public static final BigDecimal plus(BigDecimal v1,
BigDecimal v2)
minus
public static final BigDecimal minus(BigDecimal v1,
BigDecimal v2)
times
public static final BigDecimal times(BigDecimal v1,
BigDecimal v2)
divide
public static final BigDecimal divide(BigDecimal v1,
BigDecimal v2)
isGreater
public static boolean isGreater(BigDecimal v1,
BigDecimal v2)
isSmaller
public static boolean isSmaller(BigDecimal v1,
BigDecimal v2)
isEqual
public static boolean isEqual(BigDecimal v1,
BigDecimal v2)
sqrt
public static final BigDecimal sqrt(BigDecimal n)
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)
Copyright © 2010. All Rights Reserved.