Description Usage Arguments Details Value Note Author(s) References See Also Examples
Density, distribution function, quantile function, and random generation
for the triangular distribution with parameters min
, max
,
and mode
.
1 2 3 4 
x 
vector of quantiles. Missing values ( 
q 
vector of quantiles. Missing values ( 
p 
vector of probabilities between 0 and 1. Missing values ( 
n 
sample size. If 
min 
vector of minimum values of the distribution of the random variable.
The default value is 
max 
vector of maximum values of the random variable.
The default value is 
mode 
vector of modes of the random variable.
The default value is 
Let X be a triangular random variable with parameters min=
a,
max=
b, and mode=
c.
Probability Density and Cumulative Distribution Function
The density function of X is given by:
f(x; a, b, c) =  \frac{2(xa)}{(ba)(ca)}  for a ≤ x ≤ c 
\frac{2(bx)}{(ba)(bc)}  for c ≤ x ≤ b  
where a < c < b.
The cumulative distribution function of X is given by:
F(x; a, b, c) =  \frac{(xa)^2}{(ba)(ca)}  for a ≤ x ≤ c 
1  \frac{(bx)^2}{(ba)(bc)}  for c ≤ x ≤ b  
where a < c < b.
Quantiles
The p^th quantile of X is given by:
x_p =  a + √{(ba)(ca)p}  for 0 ≤ p ≤ F(c) 
b  √{(ba)(bc)(1p}  for F(c) ≤ p ≤ 1  
where 0 ≤ p ≤ 1.
Random Numbers
Random numbers are generated using the inverse transformation method:
x = F^{1}(u)
where u is a random deviate from a uniform [0, 1] distribution.
Mean and Variance
The mean and variance of X are given by:
E(X) = \frac{a + b + c}{3}
Var(X) = \frac{a^2 + b^2 + c^2  ab  ac  bc}{18}
dtri
gives the density, ptri
gives the distribution function,
qtri
gives the quantile function, and rtri
generates random
deviates.
The triangular distribution is so named because of the shape of its probability
density function. The average of two independent identically distributed
uniform random variables with parameters min=
α and
max=
β has a triangular distribution with parameters
min=
α, max=
β, and
mode=
(βα)/2.
The triangular distribution is sometimes used as an input distribution in probability risk assessment.
Steven P. Millard ([email protected])
Forbes, C., M. Evans, N. Hastings, and B. Peacock. (2011). Statistical Distributions. Fourth Edition. John Wiley and Sons, Hoboken, NJ.
Johnson, N. L., S. Kotz, and N. Balakrishnan. (1995). Continuous Univariate Distributions, Volume 2. Second Edition. John Wiley and Sons, New York.
Uniform, Probability Distributions and Random Numbers.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31  # Density of a triangular distribution with parameters
# min=10, max=15, and mode=12, evaluated at 12, 13 and 14:
dtri(12:14, 10, 15, 12)
#[1] 0.4000000 0.2666667 0.1333333
#
# The cdf of a triangular distribution with parameters
# min=2, max=7, and mode=5, evaluated at 3, 4, and 5:
ptri(3:5, 2, 7, 5)
#[1] 0.06666667 0.26666667 0.60000000
#
# The 25'th percentile of a triangular distribution with parameters
# min=1, max=4, and mode=3:
qtri(0.25, 1, 4, 3)
#[1] 2.224745
#
# A random sample of 4 numbers from a triangular distribution with
# parameters min=3 , max=20, and mode=12.
# (Note: the call to set.seed simply allows you to reproduce this example.)
set.seed(10)
rtri(4, 3, 20, 12)
#[1] 11.811593 9.850955 11.081885 13.539496

Attaching package: 'EnvStats'
The following objects are masked from 'package:stats':
predict, predict.lm
The following object is masked from 'package:base':
print.default
[1] 0.4000000 0.2666667 0.1333333
[1] 0.06666667 0.26666667 0.60000000
[1] 2.224745
[1] 11.811593 9.850955 11.081885 13.539496
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.