public static double lnGamma(double alpha){
  double x=alpha, f=0.0, z;
  if (x < 7) {
    f=1;
    z=x - 1;
    while (++z < 7) {
      f*=z;
    }
    x=z;
    f=-Math.log(f);
  }
  z=1 / (x * x);
  return f + (x - 0.5) * Math.log(x) - x + 0.918938533204673 + (((-0.000595238095238 * z + 0.000793650793651) * z - 0.002777777777778) * z + 0.083333333333333) / x;
}

public static double lnGamma ( double alpha ) { double x = alpha , f = 0.0 , z ; if ( x < 7 ) { f = 1 ; z = x - 1 ; while ( ++ z < 7 ) { f *= z ; } x = z ; f = - Math . log ( f ) ; } z = 1 / ( x * x ) ; return f + ( x - 0.5 ) * Math . log ( x ) - x + 0.918938533204673 + ( ( ( - 0.000595238095238 * z + 0.000793650793651 ) * z - 0.002777777777778 ) * z + 0.083333333333333 ) / x ; }
log gamma function : ln ( gamma ( alpha ) ) for alpha > 0 , accurate to 10 decimal places
