Skip to content
Prev 6298 / 63424 Next

possible bugs: boundary conditions and random distribution parameters

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.  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.

  The fixes seem straightforward.

  Ben Bolker