Date: Fri, 16 Jun 2000 16:14:34 GMT Dale McLerran "SAS(r) Discussion" Dale McLerran Fred Hutchinson Cancer Research Center Re: RANGAM(seed,a) problem

Barrere,

A two parameter gamma distribution with shape parameter r and scale parameter lambda is obtained from the rangam function by specifying

x = lambda*rangam(seed,r);

Now, the question is how do lambda and r relate to the mean and variance. The mean mu is r/lambda, while the variance is mu/lambda. Inverting these functions to solve for r and lambda as functions of the mean and variance, we get lambda=mu/var and r=(mu**2)/var. So, to generate a gamma distributed random variate with mean mu and variance var, you would specify

lambda = mu/var; r = mu*lambda; x = lambda*rangam(seed,r);

Hope this helps.

Dale

-------------------------------------- Dale McLerran Fred Hutchinson Cancer Research Center Seattle, WA 98109 mailto:dmclerra@fhcrc.org ph: (206) 667-2926 fax: (206) 667-5977 --------------------------------------

bendiabarre@ALTAVISTA.COM (barrere bendia) wrote in <20000616143543.7382.cpmta@c012.sfo.cp.net>:

>Hi > I wante to generate number according gamma distribution > with mean=mu and variance=mu(square) r. > > I tried the functin: RANGAM(seed,a) but what dos mean the > parameter a.,sinct the GAMMA distribution has two > parameters(: mu and nu). > > Can I do like this: > do i=1 to 100; > gama= mu + sqrt(var)*RANGAM(seed,mu); > output; > end; > drop i; > ? > Thank you all.

Back to: Top of message | Previous page | Main SAS-L page