JLLib.MathFun
Class Sfun

java.lang.Object
  extended byJLLib.MathFun.Sfun

public class Sfun
extends java.lang.Object

Collection of special functions.


Field Summary
private static double[] ALNRCS_COEF
           
private static double[] ASINH_COEF
           
private static double[] ATANH_COEF
           
protected static double big
           
protected static double biginv
           
private static double[] COT_COEF
           
static double EPSILON_LARGE
          The largest relative spacing for doubles.
static double EPSILON_SMALL
          The smallest relative spacing for doubles.
private static double[] ERFC_COEF
           
private static double[] ERFC2_COEF
           
private static double[] ERFCC_COEF
           
private static double[] GAMMA_COEF
           
protected static double[] logFactorials
          Returns log(k!).
protected static double LOGPI
           
protected static double MACHEP
           
protected static double MAXGAM
           
protected static double MAXLOG
           
protected static double MINLOG
           
private static double[] R9LGMC_COEF
           
private static double[] SINH_COEF
           
protected static double SQRTH
           
protected static double SQTPI
           
private static double[] TANH_COEF
           
 
Constructor Summary
private Sfun()
          Private contructor, so nobody can make an instance of this class.
 
Method Summary
static double acosh(double x)
          Returns the inverse (arc) hyperbolic cosine of a double.
static double asinh(double x)
          Returns the inverse (arc) hyperbolic sine of a double.
static double atanh(double x)
          Returns the inverse (arc) hyperbolic tangent of a double.
static double cosh(double x)
          Returns the hyperbolic cosine of a double.
static double cot(double x)
          Returns the cotangent of a double.
(package private) static double csevl(double x, double[] coef)
           
private static double dlnrel(double x)
           
static double erf(double x)
          Returns the error function of a double.
static double erfc(double x)
          Returns the complementary error function of a double.
static double factorial(int n)
          Returns the factorial of an integer.
static double gamma(double x)
          Returns the Gamma function of a double.
static double incompleteBeta(double aa, double bb, double xx)
          Returns the Incomplete Beta Function evaluated from zero to xx; formerly named ibeta.
(package private) static double incompleteBetaFraction1(double a, double b, double x)
          Continued fraction expansion #1 for incomplete beta integral; formerly named incbcf.
(package private) static double incompleteBetaFraction2(double a, double b, double x)
          Continued fraction expansion #2 for incomplete beta integral; formerly named incbd.
static double incompleteGamma(double a, double x)
          Returns the Incomplete Gamma function; formerly named igamma.
static double incompleteGammaComplement(double a, double x)
          Returns the Complemented Incomplete Gamma function; formerly named igamc.
static double log10(double x)
          Returns the common (base 10) logarithm of a double.
static double logBeta(double a, double b)
          Returns the logarithm of the Beta function.
static double logFactorial(int k)
           
static double logGamma(double x)
          Returns the logarithm of the Gamma function of a double.
(package private) static double powerSeries(double a, double b, double x)
          Power series for incomplete beta integral; formerly named pseries.
static double psi(double x)
           
(package private) static double r9lgmc(double x)
           
private static double sign(double x, double y)
           
static double sinh(double x)
          Returns the inverse (arc) hyperbolic sine of a double.
static double tanh(double x)
          Returns the hyperbolic tangent of a double.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MACHEP

protected static final double MACHEP
See Also:
Constant Field Values

MAXLOG

protected static final double MAXLOG
See Also:
Constant Field Values

MINLOG

protected static final double MINLOG
See Also:
Constant Field Values

MAXGAM

protected static final double MAXGAM
See Also:
Constant Field Values

SQTPI

protected static final double SQTPI
See Also:
Constant Field Values

SQRTH

protected static final double SQRTH
See Also:
Constant Field Values

LOGPI

protected static final double LOGPI
See Also:
Constant Field Values

big

protected static final double big
See Also:
Constant Field Values

biginv

protected static final double biginv
See Also:
Constant Field Values

EPSILON_SMALL

public static final double EPSILON_SMALL
The smallest relative spacing for doubles.

See Also:
Constant Field Values

EPSILON_LARGE

public static final double EPSILON_LARGE
The largest relative spacing for doubles.

See Also:
Constant Field Values

COT_COEF

private static final double[] COT_COEF

SINH_COEF

private static final double[] SINH_COEF

TANH_COEF

private static final double[] TANH_COEF

ASINH_COEF

private static final double[] ASINH_COEF

ATANH_COEF

private static final double[] ATANH_COEF

GAMMA_COEF

private static final double[] GAMMA_COEF

R9LGMC_COEF

private static final double[] R9LGMC_COEF

ALNRCS_COEF

private static final double[] ALNRCS_COEF

ERFC_COEF

private static final double[] ERFC_COEF

ERFC2_COEF

private static final double[] ERFC2_COEF

ERFCC_COEF

private static final double[] ERFCC_COEF

logFactorials

protected static final double[] logFactorials
Returns log(k!). Tries to avoid overflows. For k<30 simply looks up a table in O(1). For k>=30 uses stirlings approximation.

Constructor Detail

Sfun

private Sfun()
Private contructor, so nobody can make an instance of this class.

Method Detail

acosh

public static double acosh(double x)
Returns the inverse (arc) hyperbolic cosine of a double.

Parameters:
x - A double value.
Returns:
The arc hyperbolic cosine of x. If x is NaN or less than one, the result is NaN.

asinh

public static double asinh(double x)
Returns the inverse (arc) hyperbolic sine of a double.

Parameters:
x - A double value.
Returns:
The arc hyperbolic sine of x. If x is NaN, the result is NaN.

atanh

public static double atanh(double x)
Returns the inverse (arc) hyperbolic tangent of a double.

Parameters:
x - A double value.
Returns:
The arc hyperbolic tangent of x. If x is NaN or |x|>1, the result is NaN.

cosh

public static double cosh(double x)
Returns the hyperbolic cosine of a double.

Parameters:
x - A double value.
Returns:
The hyperbolic cosine of x. If x is NaN, the result is NaN.

cot

public static double cot(double x)
Returns the cotangent of a double.

Parameters:
x - A double value.
Returns:
The cotangent of x. If x is NaN, the result is NaN.

csevl

static double csevl(double x,
                    double[] coef)

dlnrel

private static double dlnrel(double x)

erf

public static double erf(double x)
Returns the error function of a double.

Parameters:
x - A double value.
Returns:
The error function of x.

erfc

public static double erfc(double x)
Returns the complementary error function of a double.

Parameters:
x - A double value.
Returns:
The complementary error function of x.

factorial

public static double factorial(int n)
Returns the factorial of an integer.

Parameters:
n - An integer value.
Returns:
The factorial of n, n!. If x is negative, the result is NaN.

logFactorial

public static double logFactorial(int k)

gamma

public static double gamma(double x)
Returns the Gamma function of a double.

Parameters:
x - A double value.
Returns:
The Gamma function of x. If x is a negative integer, the result is NaN.

log10

public static double log10(double x)
Returns the common (base 10) logarithm of a double.

Parameters:
x - A double value.
Returns:
The common logarithm of x.

logBeta

public static double logBeta(double a,
                             double b)
Returns the logarithm of the Beta function.

Parameters:
a - A double value.
b - A double value.
Returns:
The natural logarithm of the Beta function.

logGamma

public static double logGamma(double x)
Returns the logarithm of the Gamma function of a double.

Parameters:
x - A double value.
Returns:
The natural logarithm of the Gamma function of x. If x is a negative integer, the result is NaN.

r9lgmc

static double r9lgmc(double x)

sign

private static double sign(double x,
                           double y)

sinh

public static double sinh(double x)
Returns the inverse (arc) hyperbolic sine of a double.

Parameters:
x - A double value.
Returns:
The arc hyperbolic sine of x. If x is NaN or less than one, the result is NaN.

tanh

public static double tanh(double x)
Returns the hyperbolic tangent of a double.

Parameters:
x - A double value.
Returns:
The hyperbolic tangent of x.

incompleteBeta

public static double incompleteBeta(double aa,
                                    double bb,
                                    double xx)
                             throws java.lang.ArithmeticException
Returns the Incomplete Beta Function evaluated from zero to xx; formerly named ibeta.

Parameters:
aa - the alpha parameter of the beta distribution.
bb - the beta parameter of the beta distribution.
xx - the integration end point.
Throws:
java.lang.ArithmeticException

powerSeries

static double powerSeries(double a,
                          double b,
                          double x)
                   throws java.lang.ArithmeticException
Power series for incomplete beta integral; formerly named pseries. Use when b*x is small and x not too close to 1.

Throws:
java.lang.ArithmeticException

incompleteBetaFraction1

static double incompleteBetaFraction1(double a,
                                      double b,
                                      double x)
                               throws java.lang.ArithmeticException
Continued fraction expansion #1 for incomplete beta integral; formerly named incbcf.

Throws:
java.lang.ArithmeticException

incompleteBetaFraction2

static double incompleteBetaFraction2(double a,
                                      double b,
                                      double x)
                               throws java.lang.ArithmeticException
Continued fraction expansion #2 for incomplete beta integral; formerly named incbd.

Throws:
java.lang.ArithmeticException

incompleteGamma

public static double incompleteGamma(double a,
                                     double x)
                              throws java.lang.ArithmeticException
Returns the Incomplete Gamma function; formerly named igamma.

Parameters:
a - the parameter of the gamma distribution.
x - the integration end point. It seems that it returns int_0^x x^(a-1) e^-x dx / Gamma(a)
Throws:
java.lang.ArithmeticException

incompleteGammaComplement

public static double incompleteGammaComplement(double a,
                                               double x)
                                        throws java.lang.ArithmeticException
Returns the Complemented Incomplete Gamma function; formerly named igamc.

Parameters:
a - the parameter of the gamma distribution.
x - the integration start point.
Throws:
java.lang.ArithmeticException

psi

public static double psi(double x)