| urtriang {Runuran} | R Documentation |
UNU.RAN random variate generator for the Triangular distribution with
shape parameters a, m and b.
It also allows sampling from the truncated distribution.
[Distribution] – Sampling Function: Triangular.
urtriang(n, a, m, b, lb=a, ub=b)
n |
size of required sample. |
a,b |
left and right boundary of domain |
m |
mode of distribution |
lb |
lower bound of (truncated) distribution. |
ub |
upper bound of (truncated) distribution. |
The Triangular distribution with domain (a,b) and mode m has a density proportional to
f(x) ~ (x-a)/(m-a)
for a <= x <= m, and
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).
This function is a wrapper for the UNU.RAN class in R.
Josef Leydold and Wolfgang H"ormann unuran@statmath.wu-wien.ac.at.
W. H"ormann, J. Leydold, and G. Derflinger (2004): Automatic Nonuniform Random Variate Generation. Springer-Verlag, Berlin Heidelberg
runif and .Random.seed about random number
generation and unuran for the UNU.RAN class.
## Create a sample of size 1000 x <- urtriang(n=1000,a=-1,m=0,b=2)