[Rd] dgamma density values in extreme point

Duncan Murdoch murdoch.duncan at gmail.com
Sun Nov 13 20:28:52 CET 2016


On 13/11/2016 1:43 PM, Alexey Burnakov wrote:
> Dear R-Devel group,
>
> My name is Alexey, a data scientist from Moscow, currently working for
> Align Technology Inc.
>
> We have recently had a discussion of the results that the dgamma
> function (stats) returns for an extreme point (x == 0).
>
>
> <dgamma(0,1,1,log = FALSE)
>
> [1] 1
>
>
> and
>
> <dgamma(0,0.5,1,log = FALSE)
> [1] Inf
>
> Density appears to be defined in point zero for the distribution with
> the said parameters.
>
> It looks like the returned value is a limit of f(x) where x --> inf.

It's the limit as x --> 0.

>
> Although several other "big" statistics engines like Wolfram and Matlab
> return 0 (zero) for gamma density with the same function parameters
> where x == 0. Which looks like a convention rather than exact answer, in
> our opinion. Is this a correct assumption?
>
> When studies scrupulously, it appears that the density is undefined when
> we get x^0 where x == 0, for example.
>
> As I could not have reached the author of the code for dgamma, could you
> comment on this behavior of the dgamma function in zero? Is it safe to
> use the function given such behaviour. Is it prudent to report density =
> inf in zero? Is there a preferable way to estimate the gamma density in
> zero otherwise?

Using the limit is the most sensible method.  Having a discontinuity in 
the density will cause more problems, e.g. if the density is used in 
quadrature.

As to the "correctness", we all know that the value of a density at any 
particular point is irrelevant.  Only the integrals of densities have 
any meaning.

Duncan Murdoch



More information about the R-devel mailing list