SuanShu, a Java numerical and statistical library

com.numericalmethod.suanshu.analysis.function.special
Class LogGamma

java.lang.Object
  extended by com.numericalmethod.suanshu.analysis.function.rn2r1.UnivariateRealFunction
      extended by com.numericalmethod.suanshu.analysis.function.special.LogGamma
All Implemented Interfaces:
Function, RealScalarFunction

public class LogGamma
extends UnivariateRealFunction

This computes an approximation to the log Gamma function, log(Γ(z)), for positive real numbers.

We provide a few ways to compute log(Γ(z)). Each method differs in accuracy and speed. For example,

The full Lanczos approximation can be made arbitrarily precise because it is computed using BigDecimal.

The quick Lanczos approximation is quick but could be less precise because the computations are done in double precision.

See Also:

Nested Class Summary
static class LogGamma.Method
          the methods available to compute log(Γ(z))
 
Nested classes/interfaces inherited from interface com.numericalmethod.suanshu.analysis.function.Function
Function.EvaluationException
 
Constructor Summary
LogGamma()
          Construct an instance to compute for log Gamma function with default settings.
LogGamma(LogGamma.Method method, double g, int n, int scale)
          Construct an instance to compute for log Gamma function.
 
Method Summary
 double evaluate(double x)
          Compute for the Gamma function in the positive Real domain.
 
Methods inherited from class com.numericalmethod.suanshu.analysis.function.rn2r1.UnivariateRealFunction
dimension4Domain, dimension4Range, evaluate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LogGamma

public LogGamma()
Construct an instance to compute for log Gamma function with default settings.


LogGamma

public LogGamma(LogGamma.Method method,
                double g,
                int n,
                int scale)
Construct an instance to compute for log Gamma function.

Recommended settings are

g = 607.0 / 128.0 n = 15 scale = 30

Parameters:
method - the algorithm to use, which affects only precision
g - g
n - n
scale - precision
Method Detail

evaluate

public double evaluate(double x)
Compute for the Gamma function in the positive Real domain.

Specified by:
evaluate in class UnivariateRealFunction
Parameters:
x - a real number > 0
Returns:
log(Γ(z))

SuanShu, a Java numerical and statistical library

Copyright © 2011 Numerical Method Inc. Ltd. All Rights Reserved.