I am late to this discussion so forgive me if I am being redundant. It appears to me that the integral from 0 to infinity of log-gamma may diverge to infinity. Equation 6.1.50 of Abramowitz & Stegun shows that a re-expression of lnGamma(x) and the Stirling approximation involves (x-1/2)*log(x) -x along with other terms. This term appears to dominate the integral and itself diverge. It is worth checking out.
> integrate(lgamma, lower = 0, upper = 10) 43.24636 with absolute error < 1.6e-11 > integrate(lgamma, lower = 0, upper = 100) 15438.12 with absolute error < 1.4 > integrate(lgamma, lower = 0, upper = 1000) 2701843 with absolute error < 254 > integrate(lgamma, lower = 0, upper = 10000) 385485116 with absolute error < 18464 > gterm <- function(x){(x-.5)*log(x)-x} > integrate(gterm,lower=0,upper=10) 33.61633 with absolute error < 1.1e-05 > integrate(gterm,lower=0,upper=100) 15345.59 with absolute error < 1.2 > integrate(gterm,lower=0,upper=1000) 2700923 with absolute error < 252 > integrate(gterm,lower=0,upper=10000) 385475926 with absolute error < 18462 > Joseph F. Lucke Senior Statistician Research Institute on Addictions University at Buffalo State University of New York 1021 Main Street Buffalo, NY 14203-1016 Office: 716-887-6807 Fax: 716-887-2510 http://www.ria.buffalo.edu/profiles/lucke.html "Andreas Wittmann" <andreas_wittm...@gmx.de> Sent by: r-help-boun...@r-project.org 04/22/2009 03:28 AM To r-help@r-project.org cc Subject [R] integrate lgamma from 0 to Inf Dear R users, i try to integrate lgamma from 0 to Inf. But here i get the message "roundoff error is detected in the extrapolation table", if i use 1.0e120 instead of Inf the computation works, but this is against the suggestion of integrates help information to use Inf explicitly. Using stirlings approximation doesnt bring the solution too. ## Stirlings approximation lgammaApprox <- function(x) { 0.5*log(2*pi)+(x-(1/2))*log(x)-x } integrate(lgamma, lower = 0, upper = 1.0e120) integrate(lgammaApprox, lower = 0, upper = 1.0e120) > integrate(lgamma, lower = 0, upper = 1.0e120) 1.374051e+242 with absolute error < 3.2e+235 > integrate(lgammaApprox, lower = 0, upper = 1.0e120) 1.374051e+242 with absolute error < 3.2e+235 integrate(lgamma, lower = 0, upper = Inf) integrate(lgammaApprox, lower = 0, upper = Inf) > integrate(lgamma, lower = 0, upper = Inf) Fehler in integrate(lgamma, lower = 0, upper = Inf) : roundoff error is detected in the extrapolation table > integrate(lgammaApprox, lower = 0, upper = Inf) Fehler in integrate(lgammaApprox, lower = 0, upper = Inf) : roundoff error is detected in the extrapolation table Many thanks if you have any advice for me! best regards Andreas -- ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.