These functions implement a custom distribution combining a trapezoidal section (0 < x < a) and an exponential tail (\(x \geq a\)). The distribution is parameterized by:
a: transition point between trapezoid and exponentialell: rate parameter for the exponential tail
Usage
dtzexp(x, a, ell, log = FALSE)
ptzexp(q, a, ell, lower.tail = TRUE, log.p = FALSE)
qtzexp(p, a, ell, lower.tail = TRUE, log.p = FALSE)
rtzexp(n, a, ell)Arguments
- x, q
vector of quantiles
- a
location parameter for transition (must be > 0)
- ell
rate parameter for exponential decay (must be > 0)
- log, log.p
logical; return or accept probabilities on the log scale.
- lower.tail
logical; if FALSE, use upper-tail probabilities.
- p
vector of probabilities
- n
number of observations
Value
dtzexpgives the densityptzexpgives the distribution functionqtzexpgives the quantile functionrtzexpgenerates random deviates
Details
Density, distribution function, quantile function and random generation for a custom trapezoid + exponential distribution.
The trapezoid+exponential distribution has the probability density function:
$$ f(x) = \begin{cases} 0 & \text{if } x \leq 0 \\ \frac{(p\ell - c)}{a} x + c & \text{if } 0 < x < a \\ p\ell e^{-\ell (x - a)} & \text{if } x \geq a \end{cases} $$
where: $$ p = \frac{\ell - \frac{a\ell}{3}}{\frac{a^2\ell^2}{6} + \frac{2a\ell}{3} + 1} $$ $$ c = \frac{2 - 2p - p\ell a}{a} $$ Parameters must also satisfy \(0 \leq p \leq 1\) and \(c \geq 0\). Invalid parameter combinations produce an error. If \(p=0\), the distribution has bounded support \([0,a]\).
Random values are generated by inversion of the CDF. This changes the random draws from earlier versions for the same seed.
The trapezoid+exponential distribution has the following characteristics:
Support on \([0, \infty)\)
Continuous probability distribution
Linear density from 0 to a
Exponential decay for x > a