[R] Incomplete Gamma function

Robin Hankin r.hankin at noc.soton.ac.uk
Fri Aug 31 16:01:26 CEST 2007


On 31 Aug 2007, at 14:06, Prof Brian Ripley wrote:

> On Fri, 31 Aug 2007, Robin Hankin wrote:
>
>> Hi Kris
>>
>>
>> lgamma() gives the log of the gamma function.
>
> Yes, but he used Igamma.  According to ?pgamma,
>
>      'pgamma' is closely related to the incomplete gamma function.  As
>      defined by Abramowitz and Stegun 6.5.1
>
>          P(a,x) = 1/Gamma(a) integral_0^x t^(a-1) exp(-t) dt
>
>      P(a, x) is 'pgamma(x, a)'.  Other authors (for example Karl
>      Pearson in his 1922 tables) omit the normalizing factor, defining
>      the incomplete gamma function as 'pgamma(x, a) * gamma(a)'.
>
> and that seems to be what Igamma is following.  GSL on the other  
> hand has the other tail, so
>
>> a <- 9
>> x <- 11.1
>> pgamma(x, a, lower=FALSE)*gamma(a)
> [1] 9000.501
>
>>
>> You need gamma_inc() of the gsl package, a wrapper for the
>> GSL library:
>>
>> > gamma_inc(9,11.1)
>> [1] 9000.501
>> >
>
> As the above shows, you don't *need* this, but you do need the GSL  
> documentation to find out what R package gsl does.  Why it differs  
> from the usual references is something for you to explain.  Wikipedia
> http://en.wikipedia.org/wiki/Incomplete_gamma_function
> distinguishes them, as does MathWorld.
>
> I suggest you add a clarification to the gsl package as to what the  
> 'incomplete gamma function' means there.

GSL gives both tails for the normalized incomplete gamma function but  
not the unnormalized version, for which
only the upper incomplete gamma function is given.

This seems a strange omission; I'll raise it on the GSL mailing list.

re your request for clarification in the gsl helpfiles:  I'm  
uncertain about this.
The gsl library is supposed to be a "no-brainer" wrapper for GSL  
functions;  anything
documented in .Rd files will be 100% dominated by gsl-ref [the GSL  
manual].   That's
why the documentation in gsl is restricted to the rather curt  "see  
the GSL documentation".

But I appreciate that this seems rather unhelpful.

Best wishes



rksh




--
Robin Hankin
Uncertainty Analyst
National Oceanography Centre, Southampton
European Way, Southampton SO14 3ZH, UK
  tel  023-8059-7743



More information about the R-help mailing list