Re: [R] The gamma function and infinity

From: Ted Harding <Ted.Harding_at_nessie.mcc.ac.uk>
Date: Tue 06 Dec 2005 - 03:29:24 EST


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

Does this help?

Ted.



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

______________________________________________
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Tue Dec 06 03:52:19 2005

This archive was generated by hypermail 2.1.8 : Tue 06 Dec 2005 - 04:25:59 EST