[R] rgamma with negative shape and scale parameters works?
Peter Dalgaard BSA
p.dalgaard at biostat.ku.dk
Fri Apr 14 18:44:43 CEST 2000
Faheem Mitha <faheem at email.unc.edu> writes:
> 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
Most likely, it is a bug(let). Calculating dgamma(rgamma(... with the
same parameters give NaN.
--
O__ ---- Peter Dalgaard Blegdamsvej 3
c/ /'_ --- Dept. of Biostatistics 2200 Cph. N
(*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk) FAX: (+45) 35327907
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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