# herlang: Hyper-Erlang Distribution In mapfit: A Tool for PH/MAP Parameter Estimation

 herlang R Documentation

## Hyper-Erlang Distribution

### Description

Density function, distribution function and random generation for the hyper-Erlang distribution, and a function to generate an object of herlang.

### Usage

herlang(
shape,
mixrate = rep(1/length(shape), length(shape)),
rate = rep(1, length(shape))
)

dherlang(x, herlang = herlang(shape = c(1)), log = FALSE)

pherlang(q, herlang = herlang(shape = c(1)), lower.tail = TRUE, log.p = FALSE)

rherlang(n, herlang = herlang(shape = c(1)))


### Arguments

 shape An integer vector of shape parameters of Erlang components. mixrate A vector for the initial probabilities of hyper-Erlang distribution. rate A vector of rate parameters of Erlang components. x Vectors of quantiles. herlang An object of S4 class of hyper Erlang (herlang). log Logical; if TRUE, the log density is returned. q Vectors of quantiles. lower.tail Logical; if TRUE, probabilities are P[X <= x], otherwise, P[X > x]. log.p Logical; if TRUE, the log probability is returned. n Number of observations. p A vector of probabilities.

### Details

The hyper-Erlang distribution with parameters m_i (mixrate), s_i (shape) and r_i (rate): Cumulative probability function;

F(q) = ∑_i \int_0^q m_i \frac{r_i^{s_i} x^{s_i-1} e^{-r_i x}}{(s_i - 1)!} dx

Probability density function;

f(x) = ∑_i m_i \frac{r_i^{s_i} x^{s_i-1} e^{-r_i x}}{(s_i - 1)!}

### Value

herlang gives an object of hyper-Erlang distribution. dherlang gives the density function, pherlang gives the distribution function, and rherlang generates random samples.

### Note

herlang requires shape parameters.

ph, herlang

### Examples

## create a hyper Erlang consisting of two Erlang
## with shape parameters 2 and 3.
(param1 <- herlang(c(2,3)))

## create a hyper Erlang consisting of two Erlang
## with shape parameters 2 and 3.
(param1 <- herlang(shape=c(2,3)))

## create a hyper Erlang with specific parameters
(param2 <- herlang(shape=c(2,3), mixrate=c(0.3,0.7), rate=c(1.0,10.0)))

## convert to a general PH
as(param2, "ph")

## p.d.f. for 0, 0.1, ..., 1
(dherlang(x=seq(0, 1, 0.1), herlang=param2))

## c.d.f. for 0, 0.1, ..., 1
(pherlang(q=seq(0, 1, 0.1), herlang=param2))

## generate 10 samples
(rherlang(n=10, herlang=param2))



mapfit documentation built on May 30, 2022, 9:07 a.m.