Functions to compute the probability density function, cumulative distribution function, and quantile function for the Laplace (double exponential) distribution.
The PDF is
$$f(x; \mu, \sigma) = \frac{1}{2\sigma}\exp\left(-\frac{|x-\mu|}{\sigma}\right)$$
and the CDF is
$$F(x) = \begin{cases}\exp\left(\frac{x-\mu}{\sigma}\right) / \sigma, & x < \mu,\\ 1 - \exp\left(\frac{x-\mu}{\sigma}\right) / \sigma, & x \ge \mu.\end{cases}$$
Usage
laplace_distribution(location = 0, scale = 1)
laplace_pdf(x, location = 0, scale = 1)
laplace_lpdf(x, location = 0, scale = 1)
laplace_cdf(x, location = 0, scale = 1)
laplace_lcdf(x, location = 0, scale = 1)
laplace_quantile(p, location = 0, scale = 1)Value
A single numeric value with the computed probability density, log-probability density, cumulative distribution, log-cumulative distribution, or quantile depending on the function called.
See also
Boost Documentation for more details on the mathematical background.
Examples
# Laplace distribution with location = 0, scale = 1
dist <- laplace_distribution(0, 1)
# Apply generic functions
cdf(dist, 0.5)
#> [1] 0.6967347
logcdf(dist, 0.5)
#> [1] -0.3613506
pdf(dist, 0.5)
#> [1] 0.3032653
logpdf(dist, 0.5)
#> [1] -1.193147
hazard(dist, 0.5)
#> [1] 1
chf(dist, 0.5)
#> [1] 1.193147
mean(dist)
#> [1] 0
median(dist)
#> [1] 0
mode(dist)
#> [1] 0
range(dist)
#> [1] -Inf Inf
quantile(dist, 0.2)
#> [1] -0.9162907
standard_deviation(dist)
#> [1] 1.414214
support(dist)
#> [1] -Inf Inf
variance(dist)
#> [1] 2
skewness(dist)
#> [1] 0
kurtosis(dist)
#> [1] 6
kurtosis_excess(dist)
#> [1] 3
# Convenience functions
laplace_pdf(0)
#> [1] 0.5
laplace_lpdf(0)
#> [1] -0.6931472
laplace_cdf(0)
#> [1] 0.5
laplace_lcdf(0)
#> [1] -0.6931472
laplace_quantile(0.5)
#> [1] 0