[R] rgamma question

Thomas Lumley tlumley at u.washington.edu
Fri Feb 6 00:26:05 CET 2004


On Thu, 5 Feb 2004, Icabalceta, Jorge L. wrote:

> I was trying to generate random numbers with a gamma distribution. In R the
> function is:
> rgamma(n, shape, rate = 1, scale = 1/rate). My question is that if
> X~gamma(alpha, beta) and I want to generate one random number where do I
> plug alpha and beta in rgamma? and, what is the meaning and use of rate?

It depends on what you mean by gamma(alpha,beta). It could be
	rgamma(1,alpha,beta)
or
 	rgamma(1,alpha,1/beta)
since both of these parameterisations are used.

If you think the mean of gamma(alpha,beta) is alpha*beta, use the second
one, if you think it is alpha/beta use the first one.

	-thomas




More information about the R-help mailing list