The Laplace distribution, also known as the double exponential distribution, is a continuous probability distribution that is symmetric around its location parameter.
dist_laplace(mu, sigma)We recommend reading this documentation on pkgdown which renders math nicely. https://pkg.mitchelloharawild.com/distributional/reference/dist_laplace.html
In the following, let \(X\) be a Laplace random variable with location
parameter mu = \(\mu\) and scale parameter sigma = \(\sigma\).
Support: \(R\), the set of all real numbers
Mean: \(\mu\)
Variance: \(2\sigma^2\)
Probability density function (p.d.f):
$$ f(x) = \frac{1}{2\sigma} \exp\left(-\frac{|x - \mu|}{\sigma}\right) $$
Cumulative distribution function (c.d.f):
$$ F(x) = \begin{cases} \frac{1}{2} \exp\left(\frac{x - \mu}{\sigma}\right) & \text{if } x < \mu \\ 1 - \frac{1}{2} \exp\left(-\frac{x - \mu}{\sigma}\right) & \text{if } x \geq \mu \end{cases} $$
Moment generating function (m.g.f):
$$ E(e^{tX}) = \frac{\exp(\mu t)}{1 - \sigma^2 t^2} \text{ for } |t| < \frac{1}{\sigma} $$
extraDistr::Laplace
dist <- dist_laplace(mu = c(0, 2, -1), sigma = c(1, 2, 0.5))
dist
#> <distribution[3]>
#> [1] Laplace(0, 1) Laplace(2, 2) Laplace(-1, 0.5)
mean(dist)
#> [1] 0 2 -1
variance(dist)
#> [1] 2.0 8.0 0.5
skewness(dist)
#> [1] 0 0 0
kurtosis(dist)
#> [1] 3 3 3
generate(dist, 10)
#> [[1]]
#> [1] -1.11769517 -0.05775841 0.57383162 -0.61663591 0.24395152 -0.30607448
#> [7] 0.25300914 -0.18739964 -0.85617486 0.62640001
#>
#> [[2]]
#> [1] 1.8314313 -1.2275679 3.5544361 -1.2842394 -3.9253502 1.3046969
#> [7] 1.1494476 2.1724914 2.3269413 0.5391549
#>
#> [[3]]
#> [1] -1.99248887 0.00389331 -2.03782638 -1.13589006 -1.27103502 -1.89021872
#> [7] -1.07026010 -0.51243633 -1.42817940 -0.65537543
#>
density(dist, 0)
#> [1] 0.50000000 0.09196986 0.13533528
density(dist, 0, log = TRUE)
#> [1] -0.6931472 -2.3862944 -2.0000000
cdf(dist, 1)
#> [1] 0.8160603 0.3032653 0.9908422
quantile(dist, 0.7)
#> [1] 0.5108256 3.0216512 -0.7445872