R/rtriangular.R

rtriangular <-
function(n,a,b){
if(b<=a) stop("b should be greater than a")  
u=runif(n)
x=ifelse(u<0.5,2*a+(b-a)*sqrt(2*u),2*b-(b-a)*sqrt(2*(1-u)))
if(b>a) 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.