[R] rgamma with negative shape and scale parameters works?

Faheem Mitha faheem at email.unc.edu
Fri Apr 14 18:30:44 CEST 2000


Dear R people,

This is a possibly silly question, but the rgamma function takes the shape
and scale arguments and simulates gamma rvs corresponding to those values,
right? But the shape and scale parameters have to be positive, right?
However, rgamma quite happily returns to me values for negative values of
shape and scale, and in some cases returns negative values eg.

> rgamma(1, 1, -1)
[1] -1.011081
> rgamma(1, -1, -1)
[1] -1.710464
> rgamma(1, -1, 1)
[1] 2.058639

What is with this? Is some generalised version of gamma being used or
what? Can someone enlighten me? Thanks.
                                              Faheem.

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help 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-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list