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.

Reply via email to