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.36711211 0.41731557 0.16381514 -0.66221683 -1.76133439 1.15992222
#> [7] -1.63859856 -0.08484774 -3.42374992 0.29025085
#>
#> [[2]]
#> [1] 1.84052207 1.25746756 3.43749205 -1.72211123 1.09198626 -0.01766638
#> [7] 7.10521169 3.79418775 8.30334282 -1.32393260
#>
#> [[3]]
#> [1] -0.79896108 -0.37234528 -1.28012352 -0.94928966 -1.45270781 0.08059396
#> [7] -0.81478629 0.09223017 -1.98185496 -1.96915562
#>
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