java.lang.Object
org.cicirello.math.MathFunctions
MathFunctions is a class of utility methods that implement various mathematical functions.
-
Method Summary
Modifier and TypeMethodDescriptionstatic double
betai
(double a, double b, double x) Computes the incomplete beta function: IX(a, b).static double
logGamma
(double n) Implementation of the natural log of the absolute value of the gamma function.static double
pow
(double a, int b) Computes ab, where the exponent b is an integer.
-
Method Details
-
betai
public static double betai(double a, double b, double x) Computes the incomplete beta function: IX(a, b).- Parameters:
a
- the parameter, a, of the incomplete beta functionb
- the parameter, b, of the incomplete beta functionx
- the parameter, x, of the incomplete beta function- Returns:
- IX(a, b)
- Throws:
IllegalArgumentException
- if x is negative or greater than 1ArithmeticException
- if the continued fraction evaluation fails to converge, such as if either a or b are too large, or if the continued fraction evaluation is using too few iterations
-
pow
public static double pow(double a, int b) Computes ab, where the exponent b is an integer. This is more efficient than usingMath.pow(double, double)
since it exploits the integer type of the exponent.- Parameters:
a
- The base.b
- The exponent.- Returns:
- ab
-
logGamma
public static double logGamma(double n) Implementation of the natural log of the absolute value of the gamma function.- Parameters:
n
- input parameter to the function- Returns:
- ln(abs(gamma(n)))
-