At 04:53 PM 10/24/2009, R_help Help wrote:
Hi - I ran into a problem when the argument to gamma function is
large. Says, if I do the following:
> gamma(17000)
[1] Inf
Warning message:
value out of range in 'gammafn'
Is there anyway to get around this or other implementation? Thank you.
-rc
Try the log of the gamma function instead:
> ? gamma
> lgamma(17000)
[1] 148592.5
> (17000-0.5)*log(17000)-17000+0.5*log(2*pi)
[1] 148592.5
Note that, for this size number, the first few terms of the usual
expansions gives the answer to 7 significant figures.
I will restrain myself from asking the obvious question of what
possible use gamma(17000) could be to you, and why a simple
"infinity" would not work just as well. I'm sure you must have good
reason for your request.
================================================================
Robert A. LaBudde, PhD, PAS, Dpl. ACAFS e-mail: r...@lcfltd.com
Least Cost Formulations, Ltd. URL: http://lcfltd.com/
824 Timberlake Drive Tel: 757-467-0954
Virginia Beach, VA 23464-3239 Fax: 757-467-2947
"Vere scire est per causas scire"
______________________________________________
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.