triang {skewunit} | R Documentation |
The triangular distribution
Description
Density, distribution function and random generation for the triangular distribution.
Usage
dtriang(x, log=FALSE)
ptriang(q, lower.tail=TRUE, log.p=FALSE)
rtriang(n)
Arguments
x , q |
vector of quantiles. |
n |
number of observations. If length(n) > 1, the length is taken to be the number required. |
log , log.p |
logical; if TRUE, probabilities p are given as log(p). |
lower.tail |
logical; if TRUE (default), probabilities are |
Details
The triangular distribution has density
f(x) = \left\{
\begin{array}{lr}
4x, & 0\leq x\leq 1/2,\\
4(1-x), & 1/2<x\leq 1,
\end{array}
\right.
and cumulative distribution function
F(x) = \left\{
\begin{array}{lr}
2x^2, & 0\leq x\leq 1/2,\\
2x^2-(2x-1)^2, & 1/2<x\leq 1,
\end{array}
\right.
Value
dtriang gives the density, ptriang gives the distribution function, and rtriang generates random deviates. The length of the result is determined by n for rasin, and is the maximum of the lengths of the numerical arguments for the other functions. The numerical arguments other than n are recycled to the length of the result. Only the first elements of the logical arguments are used.
Author(s)
Diego Gallardo
Examples
dtriang(0.5)
ptriang(0.5)
rtriang(5)