def gammaln(x):
 x = (x - 1.0)
 y = (x + 5.5)
 y = (((x + 0.5) * log(y)) - y)
 n = 1.0
 for i in xrange(6):
  x += 1
  n += ((76.18009173, (-86.50532033), 24.01409822, (-1.231739516), 0.00120858003, (-5.36382e-06))[i] / x)
 return (y + log((2.50662827465 * n)))

def gammaln ( x ) : x = ( x - 1.0 ) y = ( x + 5.5 ) y = ( ( ( x + 0.5 ) * log ( y ) ) - y ) n = 1.0 for i in xrange ( 6 ) : x += 1 n += ( ( 76.18009173 , ( - 86.50532033 ) , 24.01409822 , ( - 1.231739516 ) , 0.00120858003 , ( - 5.36382e-06 ) ) [ i ] / x ) return ( y + log ( ( 2.50662827465 * n ) ) )
returns the natural logarithm of the gamma function at x .