|
Holger's Java API |
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.antelmann.math.MyMath
public final class MyMath
some math related static functions including some useful statistics functions
| Field Summary | |
|---|---|
static double |
FIB
the neares quotient of Fibonacci numbers as double |
static Comparator<Number> |
NUMBER_COMPARATOR
|
| Method Summary | ||
|---|---|---|
static String |
asFormattedString(long bytes,
boolean si)
source taken from the Internet; use it w/ si=true for file sizes |
|
static double |
average(double... population)
returns mean(population) |
|
static Comparator<Object> |
getStringNumberComparator()
|
|
static boolean |
isNumber(Object obj)
|
|
static boolean |
isNumberType(Class<?> type)
|
|
static Object |
max(Object... values)
|
|
static double |
maxDouble(double... value)
returns the greatest element out of the given array |
|
static float |
maxFloat(float... value)
returns the greatest element out of the given array |
|
static double |
maxIndex(double... value)
returns the index of the greatest element from the given array |
|
static int |
maxInt(int... value)
returns the greatest element out of the given array |
|
static long |
maxLong(long... value)
returns the greatest element out of the given array |
|
static double |
mean(double... population)
returns the mean of the population |
|
static double |
median(double... population)
returns the median of the given population |
|
static
|
median(Map<T,N> map)
|
|
static Object |
min(Object... values)
|
|
static double |
minDouble(double... value)
returns the smallest element out of the given array |
|
static double |
minIndex(double... value)
returns the index of the smallest element from the given array |
|
static int |
minInt(int... value)
returns the greatest element out of the given array |
|
static double |
range(double... population)
returns the difference between the max and the min element |
|
static double |
roundToCurrency(double d)
Deprecated. use money instead |
|
static BigDecimal |
roundToScale(BigDecimal b,
BigDecimal scale)
|
|
static double |
roundToScale(double number,
double scale)
uses IEEEremainder |
|
static Object |
selectRandom(Collection<?> col)
randomly returns one element of the given collection (using even chances for each element) |
|
static Object |
selectRandom(Object... options)
randomly returns one of the given objects (using even chances for each element) |
|
static double |
sigmoid(double x)
produces a double between 0 and 1 with (sigmoid(0) == 0.5)
being true |
|
static double |
sigmoid(double x,
double flatteningFactor)
sigmoid(double x) is the same as sigmoid(double x, 1),
large flatteningFactor flattens the curve |
|
static int |
sign(Number n)
returns -1, 0, 1 for a negative, zero, positive number |
|
static double |
softmax(int index,
double... x)
produces a double between 0 and 1 based on the given array x and the index that must be between (0 and x.length) For further information see also: http://www-ccs.ucsd.edu/matlab/toolbox/nnet/softmax.html |
|
static double |
standardDeviation(double... population)
returns the standard deviation of the given population based on variance() |
|
static double |
stdDev(double... sample)
returns the standard deviation of the given sample based on var() |
|
static double |
sum(double... population)
returns the sum of the given population |
|
static int |
sumOfDigits(long number)
returns the sum of all individual digits. |
|
static boolean |
takeChance(double odds)
|
|
static BigDecimal |
valueOf(Number n)
|
|
static double |
var(double... sample)
returns the variance of the given sample of a population |
|
static double |
variance(double... population)
returns the variance of the given population |
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final double FIB
public static final Comparator<Number> NUMBER_COMPARATOR
| Method Detail |
|---|
public static String asFormattedString(long bytes,
boolean si)
public static boolean takeChance(double odds)
public static Object selectRandom(Collection<?> col)
public static Object selectRandom(Object... options)
public static int sumOfDigits(long number)
sumOfDigits(123045) returns 15
(1+2+3+4+0+5).
public static BigDecimal valueOf(Number n)
public static int sign(Number n)
public static Comparator<Object> getStringNumberComparator()
@Deprecated public static double roundToCurrency(double d)
Money
public static BigDecimal roundToScale(BigDecimal b,
BigDecimal scale)
public static double roundToScale(double number,
double scale)
public static double average(double... population)
mean(double[])public static double mean(double... population)
public static double sum(double... population)
public static double range(double... population)
public static double median(double... population)
public static double variance(double... population)
public static double var(double... sample)
public static double standardDeviation(double... population)
variance(double[] population)public static double stdDev(double... sample)
var(double[])public static Object max(Object... values)
public static Object min(Object... values)
public static double minDouble(double... value)
public static double maxDouble(double... value)
public static float maxFloat(float... value)
public static long maxLong(long... value)
public static int maxInt(int... value)
public static int minInt(int... value)
public static double maxIndex(double... value)
public static double minIndex(double... value)
public static double sigmoid(double x)
(sigmoid(0) == 0.5)
being true
public static double sigmoid(double x,
double flatteningFactor)
sigmoid(double x) is the same as sigmoid(double x, 1),
large flatteningFactor flattens the curve
public static double softmax(int index,
double... x)
public static <T extends Comparable<?>,N extends Number> T median(Map<T,N> map)
public static boolean isNumber(Object obj)
public static boolean isNumberType(Class<?> type)
|
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||