urtriang | 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.
[Special Generator] – 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) \sim (x-a)/(m-a)
for a \le x \le m
, and
f(x) \sim (b-x)/(b-m)
for m \le x \le 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.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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.