Hypo-Exponential Distribution

Share:

Description

Density, distribution function, quantile function, random generation and moment-generating function (and its first two derivatives) for the hypo-exponential distribution with rates rate.

Usage

1
2
3
4
5
dhypoexp(x, rate = 1, log = FALSE)
phypoexp(q, rate = 1, lower.tail = TRUE, log.p = FALSE, tailarea = FALSE)
qhypoexp(p, rate, interval = c(0.0, 1.0e+10))
rhypoexp(n = 1, rate = 1)
mgfhypoexp(x, rate = 1, difforder = 0)

Arguments

x, q

vector of quantiles.

p

vector of probabilities.

n

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

difforder

the order of derivative for the moment-generating function; currently only implemented for 0, 1, 2.

rate

vector of (unique) rates.

lower.tail

logical; if TRUE, probabilities are P(X ≤ x), otherwise P(X > x).

log, log.p

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

tailarea

logical; if TRUE, probabilities are given for the integrated tail area distribution.

interval

Passed to uniroot.

Details

The sum of n independent exponentially distributed random variables X_{i} with rate parameters λ_{i} has a hypo-exponential distribution with rate vector (λ_{1}, …, λ_{n}).

The hypo-exponential distribution is a generalization of the Erlang distribution (a Gamma distribution with an integer-valued shape parameter) and a special case of the phase-type distribution (see References section).

The quantile function is computed by numeric inversion (using uniroot).

Value

dhypoexp gives the density, phypoexp gives the distribution function (or the integrated tail area distribution function), qhypoexp gives the quantile function, rhypoexp generates random deviates and mgfhypoexp gives the moment-generating function (or its derivative up to the second order).

Note

If length(rate) == 1, dhypoexp, phypoexp and rhypoexp are equivalent to dexp, pexp and rexp with rate parameter rate and should, in fact, be replaced by the latter ones for computation speed.

References

Neuts, M. F. (1981) Matrix-Geometric Solutions in Stochastic Models: An Algorithmic Approach, reprinted and corrected.

See Also

dexp, dgamma

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
## Random generation
rhypoexp(10, c(3, 5))

## Mean
mu <- mgfhypoexp(0, c(3, 5), difforder = 1)

## Variance
mgfhypoexp(0, c(3, 5), difforder = 2) - mu^2

## Quantile
qhypoexp(0.5, c(3, 5))