[R] rexp question
Greg Snow
Greg.Snow at intermountainmail.org
Tue Aug 15 20:30:47 CEST 2006
Try:
> rexp(n=200*length(r), rate=rep(r, each=200) )
Hope this helps,
--
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
greg.snow at intermountainmail.org
(801) 408-8111
-----Original Message-----
From: r-help-bounces at stat.math.ethz.ch
[mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of Spencer Jones
Sent: Tuesday, August 15, 2006 12:15 PM
To: R-Help
Subject: [R] rexp question
I am using rexp to generate several exponential distributions. I am
passing rexp a vector of rates , r. I am wanting to simulate a sample of
size 200 for each rate so the code looks like:
rexp(n=200*length(r),rate=r) this gives me a vector of the random
exponential variables, but they are all disjointed b/c rexp goes through
and simulates an exponential variable for each rate and it does that 200
times, is there any way to get it to do it the oppisite way,i.e., 200
times in a row for each rate. I have already tried using a for loop but
it is slow.
thanks,
Spencer
[[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
and provide commented, minimal, self-contained, reproducible code.
More information about the R-help
mailing list