Dear Nicolette, You can always use the bruit force solution which works for every discrete distribution with finite number of states: let p0,p1,...,pK be the probabilities of 0,1,...,K (such that they sum up to 1). Let P <- c(p0,p1,...,pK) and P1 <- c(cumsum(P),1) Now let x = runif() (uniform in (0,1)) and k <- which(P1 >= x)[1] has the desired distribution.
Regards, Moshe. --- On Fri, 12/3/10, Raquel Nicolette <nicole...@ua.pt> wrote: > From: Raquel Nicolette <nicole...@ua.pt> > Subject: [R] Dicrete Laplace distribution > To: r-help@r-project.org > Received: Friday, 12 March, 2010, 2:47 AM > > > Hello, > > > > <http://tolstoy.newcastle.edu.au/R/help/04/07/0312.html#0313qlink1> > Could > anybody tell me how to generate discrete Laplacian > distribution? > > > > I need to sample uma discretised Laplacian density > like this: > > > > J( g -> g´) ~ exp (-lambda | g´ - g > |) g in {0,…, gmax} > > > > Thanks, > > > > Nicolette > > > [[alternative HTML version deleted]] > > > -----Inline Attachment Follows----- > > ______________________________________________ > 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. > ______________________________________________ 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.