triangular: The Triangular Distribution

Description Usage Arguments Details Value Examples

Description

Density, distribution function, quantile function and random generation for the triangular distribution with minimum equal to min, mode equal mode (alternatively, mean equal mean) and maximum equal to max.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
dtriang(x, min = -1, mode = 0, max = 1, log = FALSE, mean = 0)

ptriang(
  q,
  min = -1,
  mode = 0,
  max = 1,
  lower.tail = TRUE,
  log.p = FALSE,
  mean = 0
)

qtriang(
  p,
  min = -1,
  mode = 0,
  max = 1,
  lower.tail = TRUE,
  log.p = FALSE,
  mean = 0
)

rtriang(n, min = -1, mode = 0, max = 1, mean = 0)

Arguments

x, q

vector of quantiles.

min

vector of minima.

mode

vector of modes.

max

vector of maxima.

log, log.p

logical; if TRUE, probabilities p are given as log(p).

mean

Vector of means, can be specified in place of mode as an alternative parametrization.

lower.tail

logical; if TRUE (default), probabilities are P[X <= x], otherwise, P[X > x].

p

vector of probabilities.

n

number of observations. If length(n) > 1, the length is taken to be the number required.

Details

If min == mode == max, there is no density in that case and dtriang will return NaN (the error condition) (Similarity with Uniform).

mode or mean can be specified, but not both. Note: mean is the last parameter for back-compatibility. A warning will be provided if some combinations of min, mean and max leads to impossible mode.

Value

dtriang gives the density, ptriang gives the distribution function, qtriang gives the quantile function, and rtriang generates random deviates.

Examples

1
2
3
4
5
curve(dtriang(x, min=3, mode=6, max=10), from = 2, to = 11, ylab="density")
## Alternative parametrization
curve(dtriang(x, min=3, mean=6, max=10), from = 2, to = 11, add=TRUE, lty=2)
##no density when  min == mode == max
dtriang(c(1,2,3),min=2,mode=2,max=2)

mc2d documentation built on July 5, 2021, 3:01 p.m.