Bug 16972 - qpois still an error for degenerate distribution
Summary: qpois still an error for degenerate distribution
Alias: None
Product: R
Classification: Unclassified
Component: Accuracy (show other bugs)
Version: R 3.3.*
Hardware: Other Linux
: P5 minor
Assignee: R-core
Depends on:
Reported: 2016-06-28 11:55 UTC by t.yee@auckland.ac.nz
Modified: 2016-07-14 15:31 UTC (History)
2 users (show)

See Also:


Note You need to log in before you can comment on or make changes to this bug.
Description t.yee@auckland.ac.nz 2016-06-28 11:55:14 UTC
This is a continuation of bug 14135.

qpois(-1, 0) and qpois(2, 0) should both return NaN.
That is, when p is invalid. Currently they both
return 0 values.

Comment 1 Roby Joehanes 2016-07-13 21:12:29 UTC
This would seem to be fixable by moving the line:
if(lambda == 0) return 0;

to just above mu = lambda; line.
Comment 2 Martin Maechler 2016-07-14 07:34:51 UTC
Thank you both.  

There is one problem with the proposed resolution:

What should     qpois(p = 1, lambda = 0)

It currently gives '0'  {and that is even tested for in the regression tests},
but would give  'Inf'  with the proposed change..

Of course this case, is really a border case. Our usual reasoning is that
limits should always work, but in this case,  qpois(1, 0) may look "ill defined", as

lim{p -> 1}      qpois(p,   0)      = 0
lim{lambda -> 0} qpois(p=1, lambda) = Inf

but I think back compatibility should count more here, and more importantly,
for dpois() and ppois()  the limit behavior for  lambda --> 0  is pretty well defined  (also mentioned on the French version of the Wikipedia page), and then, as  ppois(0, 0) = 1,
for the inverse function qpois(), we really want 

                  qpois(p = 1, lambda = 0)  |-->  0
Comment 3 Martin Maechler 2016-07-14 09:36:44 UTC
Similar reasoning applies to other distributions with a limiting case of a point mass.  I think their q<dist>() functions do not deal with this issue consistently... but don't have time now to check [[don't find it too important, too]]. 
I am dealing with  

     qgeom(*, prob=1)

now, and leave other cases (if they exist) for future reports / or (better) comments to this report.