question: public static double logGamma ( final double x ) { if ( Double . isNaN ( x ) || ( x <= 0.0 ) ) { return Double . NaN ; } double g = 607.0 / 128.0 ; double tmp = x + g + .5 ; tmp = ( x + 0.5 ) * Math . log ( tmp ) - tmp ; double ser = LANCZOS [ 0 ] ; for ( int i = LANCZOS . length - 1 ; i > 0 ; -- i ) { ser += LANCZOS [ i ] / ( x + i ) ; } return tmp + Math . log ( MathUtil . SQRTTWOPI * ser / x ) ; }
target:  Compute logGamma. Based loosely on "Numerical Recpies" and the work of Paul Godfrey at http://my.fit.edu/~gabdo/gamma.txt TODO: find out which approximation really is the best...