Skip to content
Prev 199802 / 398502 Next

Generate Random Draw from Gamma Distribution Re: Monte Carlo Simulation in R...

I think he means "rate = 0.008", so he is looking for:

 rgamma(n, shape=0.067, rate=0.008)

Even then his problem is not well-posed.  You cannot have both "independent"
gamma rv's and have them sum to 2000.

Ravi.
----------------------------------------------------------------------------
-------

Ravi Varadhan, Ph.D.

Assistant Professor, The Center on Aging and Health

Division of Geriatric Medicine and Gerontology 

Johns Hopkins University

Ph: (410) 502-2619

Fax: (410) 614-9625

Email: rvaradhan at jhmi.edu

Webpage:
http://www.jhsph.edu/agingandhealth/People/Faculty_personal_pages/Varadhan.h
tml

 

----------------------------------------------------------------------------
--------


-----Original Message-----
From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On
Behalf Of David Winsemius
Sent: Tuesday, November 10, 2009 2:47 PM
To: Hongwei Dong
Cc: R-help Forum; Duncan Murdoch
Subject: Re: [R] Generate Random Draw from Gamma Distribution Re: Monte
Carlo Simulation in R...
On Nov 10, 2009, at 2:26 PM, Hongwei Dong wrote:

            
You might want to check that your parameterization in in agreement  
with that used by the rgamma function. Simply using those numbers  
yields a distribution that does not look as though it would get many  
qualifying samples. Here are 20 draws without any exclusions outside a  
range:

 >  rgamma(20, shape=0.067,  scale = 0.008)
  [1] 2.213459e-03 2.815705e-05 2.381306e-04 2.264602e-07 1.293713e-07  
7.680773e-38 6.441082e-15 6.168961e-13
  [9] 5.089033e-06 1.571858e-16 9.869878e-12 1.813121e-13 1.253287e-11  
1.852885e-04 4.212802e-07 1.774495e-25
[17] 1.892984e-07 5.927422e-17 1.322638e-12 4.327472e-05

http://finzi.psych.upenn.edu/R/Rhelp02/archive/31459.html
http://www.R-project.org/posting-guide.html
David Winsemius, MD
Heritage Laboratories
West Hartford, CT

______________________________________________
R-help at r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.