[R] Implementation of gamma function for large number

Richard M. Heiberger rmh at temple.edu
Sat Oct 24 23:03:21 CEST 2009

Use the lgamma function.

 > log(gamma(170))
[1] 701.4373
 > lgamma(170)
[1] 701.4373

In typical uses of gamma(), they are multiplied or divided
by other gamma() values, bringing the final result into the
range of double precision numbers.

Also, look at beta(), which does those divisions of gamma() for

More information about the R-help mailing list