These functions provide density, distribution function, quantile function, and random number generation for the Triangle Distribution, specified by its mean, standard deviation, and optional lower and upper bounds.
dtri(x, mode = 0, sigma = 1, upper = NA, lower = NA, log = FALSE)ptri(
q,
mode = 0,
sigma = 1,
upper = NA,
lower = NA,
lower.tail = TRUE,
log.p = FALSE
)
qtri(p, mode = 0, sigma = 1, upper = NA, lower = NA)
rtri(n, mode = 0, sigma = 1, upper = NA, lower = NA)
dtri gives the density, ptri gives the distribution function, qtri gives the quantile function, and rtri generates random deviates.
The length of the result is determined by n for rtri, 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.
numeric value or a vector of values.
numeric value or vector of mode values for the distribution.
single value or vector indicating both the positive and negative max differences from the mean (if the difference is the same).
single value or vector for the upper limit of the distribution (must be used with `lower`).
single value or vector for the lower limit of the distribution (must be used with `upper`).
logical; if TRUE, probabilities p are given as log(p).
quantile or a vector of quantiles.
logical; if TRUE, probabilities p are \(P[X\leq x]\) otherwise, \(P[X>x]\).
logical; if TRUE, probabilities p are given as log(p).
probability or a vector of probabilities.
the number of random numbers to generate.
The Triangle Distribution is defined by three points: a (minimum), b (maximum), and c (mode), where the density is zero outside the interval [a, b], increases linearly from a to c, and decreases linearly from c to b.
dtri computes the density (PDF) of the Triangle Distribution.
ptri computes the CDF of the Triangle Distribution.
qtri computes the quantile function of the Triangle Distribution.
rtri generates random numbers from the Triangle Distribution.
The mode and standard deviation parameters define the distribution's location and scale, respectively, while the lower and upper bounds explicitly set the minimum and maximum values of the distribution.
dtri(4, mode=8, upper=13, lower=1)
ptri(c(0, 1, 2, 3, 5, 7, 9, 10), mode = 3, upper=9, lower = 1)
qtri(c(0.1, 0.3, 0.5, 0.9, 0.95), mode = 3, upper = 9, lower = 1)
rtri(30, mode = 5, sigma = 3)
Run the code above in your browser using DataLab