# density function desp <- function(x,lambda) { return(lambda * exp(-lambda*x)*(x>=0)) } # cum. probability function pesp <- function(q,lambda) { return((1-exp(-lambda*q))) } # quantile function qesp <- function(p,lambda) { return(-lambda^{-1}*log(1-p)) } # random sample resp <- function(n,lambda) { return(qesp(runif(n),lambda)) } resp(100,lambda=2) # generates 100 samples from the exponential distribution with par 2
On Tue, May 11, 2010 at 6:36 PM, <khaz...@ceremade.dauphine.fr> wrote: > Hi, > At each iteration in my program,I need to generate tree vectors,X1,X2,X3, > from exponential distribution with parameters a1,a2,a3. Can you help me > please how can I do it such that it take a little time? > > thank you > khazaei > > ______________________________________________ > R-help@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. > -- +------------------------------------------------- | Patrizio Frederic, PhD | Assistant Professor, | Department of Economics, | University of Modena and Reggio Emilia, | Via Berengario 51, | 41100 Modena, Italy | | tel: +39 059 205 6727 | fax: +39 059 205 6947 | mail: patrizio.frede...@unimore.it +------------------------------------------------- ______________________________________________ R-help@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.