[Rd] behavior of r* and d* functions at boundaries (PR#1218)

bolker@zoo.ufl.edu bolker@zoo.ufl.edu
Mon, 17 Dec 2001 16:58:25 +0100 (MET)


  (Sent this to r-help back in October, got no comments, forgot
to re-submit it as a bug report.)

There are a few inconsistencies, at least, in some of the functions that 
generate random deviates from particular distributions (I think they're 
bugs because they're inconvenient, but maybe someone can make an argument 
for the current behavior). If people think these are really bugs I can 
submit them, together or separately. 

1. rlnorm(n,mean,sd) gives NaN for sd=0, rather than always returning 
the mean. This is inconsistent with rnorm(), which returns the mean. 

2. rnbinom(n,prob,size) gives NaN when prob=1; always returning 0 would be 
reasonable, and consistent with the output of dnbinom(). [This is 
equivalent to rnbinom(n,mu=0,size) in the new parameterization.] 

3. rgamma(n,shape,scale) happily returns 0 when shape=0 or scale=0. However, 
dgamma(x,shape=0) [and pgamma(x,shape=0)] gives NaN. This behavior is 
actually convenient for me, but I could make an argument for returning a 
warning in this case. 

  In general, I don't know what (e.g.) dnorm(m,mean=m,sd=0)
should return: NaN (as at present) or Inf?  I guess it depends
how fussy you're being and how you're taking limits.

  The fixes seem straightforward. 

  Ben Bolker 

Version:
 platform = i686-pc-linux-gnu
 arch = i686
 os = linux-gnu
 system = i686, linux-gnu
 status = 
 major = 1
 minor = 3.1
 year = 2001
 month = 08
 day = 31
 language = R

Search Path:
 .GlobalEnv, package:ctest, Autoloads, package:base

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._