R/rlaplace.R

rlaplace <-
function(n,beta){
if(beta<=0) stop("Beta should be positive") 
u=runif(n)
x=ifelse(u<0.5,beta*log(2*u),-beta*log(2*(1-u)))
if(beta>0) x
}

Try the OOmisc package in your browser

Any scripts or data that you put into this service are public.

OOmisc documentation built on May 1, 2019, 10:17 p.m.