public class Maths
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static double |
golden_ratio
Golden ratio: http://en.wikipedia.org/wiki/Golden_ratio
|
static double |
zero |
Constructor and Description |
---|
Maths() |
Modifier and Type | Method and Description |
---|---|
static int |
fabonacci(int n)
Fabonacci sequence.
|
static int |
factorial(int n)
Return n!
|
protected double |
gaussian(double x,
double mu,
double sigma)
Return a gaussian value with mean
mu and standard deviation sigma . |
static int |
gcd(int a,
int b)
Greatest common divisor (gcd) or greatest common factor (gcf)
|
static double |
hypot(double a,
double b)
sqrt(a^2 + b^2) without under/overflow.
|
static boolean |
isEqual(double d1,
double d2) |
static boolean |
isInt(double data) |
static boolean |
isNumber(java.lang.String string)
Check if given string is a number (digits only)
|
static boolean |
isNumberWith2Decimals(java.lang.String string)
Check if given string is number with dot separator and two decimals.
|
static boolean |
isNumeric(java.lang.String string)
Check if given string is numeric (-+0..9(.)0...9)
|
static int |
lcm(int a,
int b)
least common multiple (lcm).
|
static double |
ln(double n)
Return ln(e)=log_e(n)
|
static double |
log(double n,
int base) |
static double |
logistic(double x)
logistic function g(x)
|
static double |
logisticGradientValue(double x)
Gradient value of logistic function logistic(x).
|
static double |
logSum(double log_a,
double log_b)
Given log(a) and log(b), return log(a + b)
|
static double |
mean(java.util.Collection<? extends java.lang.Number> data)
Return mean value of a sample.
|
static double[] |
norm(double[] x) |
static double |
normalize(double x,
double min,
double max)
Get the normalized value using min-max normalizaiton.
|
static double[] |
softmax(double[] x)
logistic function g(x)
|
static double |
sum(double[] x) |
public static final double golden_ratio
(a+b)/a = a/b = phi (golden ratio) = 1.618033988749895
public static final double zero
public static boolean isEqual(double d1, double d2)
public static boolean isNumber(java.lang.String string)
string
- the given stringpublic static boolean isNumeric(java.lang.String string)
string
- the given stringpublic static boolean isNumberWith2Decimals(java.lang.String string)
string
- the given stringpublic static boolean isInt(double data)
public static int factorial(int n)
n
- the given value for n! computationpublic static double ln(double n)
n
- the given parameter of the function log_e(n)public static double log(double n, int base)
public static double logSum(double log_a, double log_b)
log_a
- log(a)
log_b
- log(b)
log(a + b)
public static double logistic(double x)
x
- the given parameter x of the function g(x)protected double gaussian(double x, double mu, double sigma)
mu
and standard deviation sigma
.x
- input valuemu
- mean of normal distributionsigma
- standard deviation of normation distributionmu
and standard deviation sigma
public static double[] softmax(double[] x) throws java.lang.Exception
x
- given parameter xjava.lang.Exception
- if error occurspublic static double[] norm(double[] x) throws java.lang.Exception
java.lang.Exception
public static double sum(double[] x)
public static double logisticGradientValue(double x)
x
- parameter x of the function logistic(x)public static double normalize(double x, double min, double max)
x
- value to be normalizedmin
- min valuemax
- max valuepublic static int fabonacci(int n)
n
- length of the sequencepublic static int gcd(int a, int b)
reference: http://en.wikipedia.org/wiki/Greatest_common_divisor
a
- given parameter a of the functionb
- given parameter b of the functionpublic static int lcm(int a, int b)
a
- given parameter a of the functionb
- given parameter b of the functionpublic static double hypot(double a, double b)
a
- given parameter a of the functionb
- given parameter b of the functionsqrt(a^2 + b^2) without under/overflow
public static double mean(java.util.Collection<? extends java.lang.Number> data)
data
- a sampleCopyright © 2017. All Rights Reserved.