[R] The gamma function and infinity

(Ted Harding) Ted.Harding at nessie.mcc.ac.uk
Mon Dec 5 17:29:24 CET 2005


On 05-Dec-05 Florent Bresson wrote:
> I have to calculate some formula like:
> 
> gamma(x)/(gamma(x+y)
> 
> and I observed that for relatively big values of x, R
> returns infinity and so cannot compute the formula. Is
> it possible to force  R to give the real value of
> gamma(x) instead of Inf ?
> 
> thanks

You should have more success with

  exp(lgamma(x) - lgamma(x+y))

E.g.

  > gamma(250)
  [1] Inf
  > exp(lgamma(250)-lgamma(251))
  [1] 0.004

= 1/250 (as it should).

Does this help?

Ted.


--------------------------------------------------------------------
E-Mail: (Ted Harding) <Ted.Harding at nessie.mcc.ac.uk>
Fax-to-email: +44 (0)870 094 0861
Date: 05-Dec-05                                       Time: 16:29:21
------------------------------ XFMail ------------------------------




More information about the R-help mailing list