Class MathFunctions

java.lang.Object
org.cicirello.math.MathFunctions

public final class MathFunctions extends Object
MathFunctions is a class of utility methods that implement various mathematical functions.
  • Method Summary

    Modifier and Type
    Method
    Description
    static 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.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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 function
      b - the parameter, b, of the incomplete beta function
      x - the parameter, x, of the incomplete beta function
      Returns:
      IX(a, b)
      Throws:
      IllegalArgumentException - if x is negative or greater than 1
      ArithmeticException - 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 using Math.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)))