Skip to content

Gamma funtion(s) bug

6 messages · Kjetil Halvorsen, Duncan Murdoch, (Ted Harding) +2 more

#
On 30-Mar-09 18:40:03, Kjetil Halvorsen wrote:
That is surely correct! Since lim[x->(-1)+] gamma(x) = +Inf,
while lim[x->(-1)-] gamma(x) = -Inf, at gamma(-1) one cannot
choose between +Inf and -Inf, so surely is is NaN.

Ted.

--------------------------------------------------------------------
E-Mail: (Ted Harding) <Ted.Harding at manchester.ac.uk>
Fax-to-email: +44 (0)870 094 0861
Date: 30-Mar-09                                       Time: 19:55:33
------------------------------ XFMail ------------------------------
#
On 3/30/2009 2:55 PM, (Ted Harding) wrote:
But lgamma(x) is log(abs(gamma(x))), so it looks okay to me.

Duncan Murdoch
#
On 30-Mar-09 20:37:51, Duncan Murdoch wrote:
Oops, yes! That's what comes of talking off the top of my head
(I don't think I've ever had occasion to evaluate lgamma(x)
for negative x, so never consciously checked in ?lgamma).

Thanks, Duncan!
Ted.

--------------------------------------------------------------------
E-Mail: (Ted Harding) <Ted.Harding at manchester.ac.uk>
Fax-to-email: +44 (0)870 094 0861
Date: 30-Mar-09                                       Time: 22:28:52
------------------------------ XFMail ------------------------------
#

        
TH> On 30-Mar-09 20:37:51, Duncan Murdoch wrote:
>> On 3/30/2009 2:55 PM, (Ted Harding) wrote:
>>> On 30-Mar-09 18:40:03, Kjetil Halvorsen wrote:
>>>> With R 2.8.1 on ubuntu I get:
    >>>>> gamma(-1)
    >>>> [1] NaN
    >>>> Warning message:
    >>>> In gamma(-1) : NaNs produced
    >>>>> lgamma(-1)
    >>>> [1] Inf
    >>>> Warning message:
    >>>> value out of range in 'lgamma'
    >>>> 
    >>>> Is'nt the first one right, and the second one (lgamma)
    >>>> should also be NaN?
    >>>> Kjetil
    >>> 
    >>> That is surely correct! Since lim[x->(-1)+] gamma(x) = +Inf,
    >>> while lim[x->(-1)-] gamma(x) = -Inf, at gamma(-1) one cannot
    >>> choose between +Inf and -Inf, so surely is is NaN.
    >> 
    >> But lgamma(x) is log(abs(gamma(x))), so it looks okay to me.
    >> 
    >> Duncan Murdoch

    TH> Oops, yes! That's what comes of talking off the top of my head
    TH> (I don't think I've ever had occasion to evaluate lgamma(x)
    TH> for negative x, so never consciously checked in ?lgamma).

    TH> Thanks, Duncan!

Indeed.... as we all know, a picture can be worth a thousand words,
and a simple R call such as
       plot(lgamma, -7, 0, n=1000)
would have saved many words, and notably spared us from
yet-another erroneous non-bug report.

Martin
#
Martin Maechler <maechler <at> stat.math.ethz.ch> writes:
In Kjetil's defense, he didn't submit an actual bug report --
and although his subject line does contain the word "bug",
I read his "bug report" as asking a question.  People are
allowed to make mistakes ...

  While I was reading ?lgamma I noticed that the "See Also"
section refers to gammaCody(), which is now defunct.  Perhaps
remove the sentence?

  Ben Bolker