[R] transform normally distributed random terms to gamma distributed random terms

Spencer Graves spencer.graves at pdf.com
Mon May 23 21:23:47 CEST 2005

	  1.  The help page for ?rgamma says E(g) = shape*scale = shape/rate 
and var(g) = shape*scale^2 = shape/rate^2.  These are different from 
what I read in your email.  Could you please check the help page more 

	  2.  If this does not solve your problem, PLEASE do read the posting 
guide! "http://www.R-project.org/posting-guide.html".  Many people 
answer their own questions in the process of preparing a posting.  If 
they don't find the answer, their question is more likely to elicit 
useful replies.  In particular, please include a brief example 
explaining why you think "rgamma" won't work for you, nor why something 
like qgamma(runif(...)) nor qgamma(pnorm(rnorm(...)))?

	  hope this helps.
	  spencer graves

Stefan Pohl wrote:
> Hi,
> I have normally distributed random terms u~N(0,1). I want to get gamma distributed random terms g~(scale,shape) with
> E(g)=1=shape/scale and var(g)=theta=1/scale=1/shape. 
> How can I reach my goal? The following way doesn't work: use the distribution function of u to get U(0,1)- distributed random
> terms, then take the quantile function of the gamma distribution with shape and scale.
> The resulting random terms must be ~gamma(shape, scale).
> But it doesn't work.
> Is there a mistake or do you know another way?
> Thanks, Stefan.
> 	[[alternative HTML version deleted]]
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

More information about the R-help mailing list