Learn R Programming

extraDistr (version 1.8.1)

DiscreteLaplace: Discrete Laplace distribution

Description

Probability mass, distribution function and random generation for the discrete Laplace distribution parametrized by location and scale.

Usage

ddlaplace(x, scale, location = 0, log = FALSE)
pdlaplace(q, scale, location = 0, lower.tail = TRUE, log.p = FALSE)
rdlaplace(n, scale, location = 0)

Arguments

x, q
vector of quantiles.
scale
scale parameter; 0 < scale < 1.
location
location parameter.
log, log.p
logical; if TRUE, probabilities p are given as log(p).
lower.tail
logical; if TRUE (default), probabilities are $P[X \le x]$ otherwise, $P[X > x]$.
n
number of observations. If length(n) > 1, the length is taken to be the number required.

Details

If $U ~ Geometric(1-p)$ and $V ~ Geometric(1-p)$, then $U-V ~ DiscreteLaplace(p)$, where geometric distribution is related to discrete Laplace distribution in similar way as exponential distribution is related to Laplace distribution.

Probability mass function

$$ f(x) = \frac{1-p}{1+p} p^{|x-\mu|} $$

Cumulative distribution function

$$ F(x) = \left\{\begin{array}{ll} \frac{p^{-|x-\mu|}}{1+p} & x < 0 \\ 1 - \frac{p^{|x-\mu|+1}}{1+p} & x \ge 0 \end{array}\right. $$

References

Inusah, S., & Kozubowski, T.J. (2006). A discrete analogue of the Laplace distribution. Journal of statistical planning and inference, 136(3), 1090-1102.

Kotz, S., Kozubowski, T., & Podgorski, K. (2012). The Laplace distribution and generalizations: a revisit with applications to communications, economics, engineering, and finance. Springer Science & Business Media.

Examples

Run this code

p <- 0.45
x <- rdlaplace(1e5, p)
xx <- seq(-200, 200, by = 1)
plot(prop.table(table(x)))
lines(xx, ddlaplace(xx, p), col = "red")
hist(pdlaplace(x, p))
plot(ecdf(x))
lines(xx, pdlaplace(xx, p), col = "red")

Run the code above in your browser using DataLab