code: public static double logGamma( double x ) {
          double ret;
  
          if (Double.isNaN(x) || (x <= 0.0)) {
              ret = Double.NaN;
          } else {
              double g = 607.0 / 128.0;
  
              double sum = 0.0;
              for( int i = LANCZOS.length - 1; i > 0; --i ) {
                  sum = sum + (LANCZOS[i] / (x + i));
              }
              sum = sum + LANCZOS[0];
  
              double tmp = x + g + .5;
              ret = ((x + .5) * log(tmp)) - tmp + HALF_LOG_2_PI + log(sum / x);
          }
  
          return ret;
      }
docs: Gamma function ported from the apache math package.
  
  <b>This should be removed if the apache math lib gets in use by HortonMachine.</b>
  
  <p>Returns the natural logarithm of the gamma function &#915;(x).
  
  The implementation of this method is based on:
  <ul>
  <li><a href="http://mathworld.wolfram.com/GammaFunction.html">
  Gamma Function</a>, equation (28).</li>
  <li><a href="http://mathworld.wolfram.com/LanczosApproximation.html">
  Lanczos Approximation</a>, equations (1) through (5).</li>
  <li><a href="http://my.fit.edu/~gabdo/gamma.txt">Paul Godfrey, A note on
  the computation of the convergent Lanczos complex Gamma approximation
  </a></li>
  </ul>
  
  @param x Value.
  @return log(&#915;(x))