Class MathUtil

java.lang.Object
org.ujmp.core.util.MathUtil

public abstract class MathUtil extends Object
  • Field Details

    • dateFormats

      private static List<DateFormat> 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

      private static final ThreadLocal<Random> randoms
    • random

      private static final Random random
  • Constructor Details

    • MathUtil

      public MathUtil()
  • Method Details

    • getRandom

      public static Random getRandom()
    • md5

      public static String md5(String text) throws NoSuchAlgorithmException
      Throws:
      NoSuchAlgorithmException
    • search

      public static final int search(long[] values, int fromIndex, int toIndex, long key)
    • md5

      public static String md5(byte[] data)
    • md5

      public static String md5(File file) throws NoSuchAlgorithmException, IOException
      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

      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.
    • collectionToLongArray

      public static final long[] collectionToLongArray(Collection<? extends Number> numbers)
    • collectionToDoubleArray

      public static final double[] collectionToDoubleArray(Collection<? extends Number> numbers)
    • collectionToIntArray

      public static final int[] collectionToIntArray(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 startInclusive, long endExclusive)
    • sequenceListLong

      public static List<Long> sequenceListLong(long startInclusive, long endExclusive, long stepsize)
    • sequenceListDouble

      public static List<Double> sequenceListDouble(double startInclusive, double endExclusive)
    • sequenceListDouble

      public static List<Double> sequenceListDouble(double startInclusive, double endExclusive, double stepsize)
    • sequenceListInt

      public static List<Integer> sequenceListInt(int startInclusive, int endExclusive)
    • 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

      public static List<Long> randPermLong(long startInclusive, long endExclusive)
    • randPermInt

      public static List<Integer> randPermInt(int startInclusive, int endExclusive)
    • 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 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)
    • max

      public static double max(double[] 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)
    • 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)
    • totalCorrect

      public static final long totalCorrect(Matrix confusionMatrix)
    • accuracy

      public static final double accuracy(Matrix confusionMatrix)
    • precisionMacro

      public static double precisionMacro(Matrix confusionMatrix)
    • recallMacro

      public static double recallMacro(Matrix confusionMatrix)
    • f1MeasureMacro

      public static double f1MeasureMacro(Matrix confusionMatrix)
    • precision

      public static double precision(Matrix confusionMatrix, long catIndex)
    • recall

      public static double recall(Matrix confusionMatrix, long catIndex)
    • f1Measure

      public static double f1Measure(Matrix confusionMatrix, long catIndex)
    • precisionMicro

      public static double precisionMicro(Matrix confusionMatrix)
    • recallMicro

      public static double recallMicro(Matrix confusionMatrix)
    • f1MeasureMicro

      public static double f1MeasureMicro(Matrix confusionMatrix)
    • 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

      public static int hexToInt(String hex)
    • intToHex

      public static String intToHex(int i)
    • isDiscrete

      public static boolean isDiscrete(double number)
    • guid

      public static String guid()