UNU.RAN random variate generator for the Triangular distribution with shape parameters a, m and b. It also allows sampling from the truncated distribution.
The Triangular distribution with domain (a,b) and mode m
has a density proportional to
f(x)∼(x−a)/(m−a)f(x)(x−a)/(m−a)
for a<=x<=m, and
f(x)∼(b−x)/(b−m)f(x)(b−x)/(b−m)
for m<=x<=b.
The generation algorithm uses fast numerical inversion. The parameters lb and ub can be used to generate variates from the Triangular distribution truncated to the interval (lb,ub).
See Also
runif and .Random.seed about random number generation and unuran for the UNU.RAN class.
References
W. H"ormann, J. Leydold, and G. Derflinger (2004): Automatic Nonuniform Random Variate Generation. Springer-Verlag, Berlin Heidelberg