lgamma(): Logarithm of the Gamma Function
lgamma() calculates the natural logarithm of the gamma function. It is useful when gamma values are enormous, because working in logarithmic space avoids overflow in likelihoods, combinatorics, and probability distributions.
Numerical meaning
For positive integers n, gamma(n) equals (n−1)!, connecting lgamma to factorial(). Use gamma() when the unlogged value is required, and exp() to reconstruct a representable result.
Gamma has poles at zero and negative integers. Check the domain before evaluating, especially in parameter estimation, and prefer log-space subtraction over dividing giant gamma values directly.