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.5986614 0.6264753 0.7691648 2.4482877 -0.3940295 -0.5887575
#> [7] -0.2251037 -0.7339940 -0.3397474 -0.4709596
#>
#> [[2]]
#> [1] 4.9802827 0.2987205 1.1569862 2.7732591 4.7342242 2.8346311
#> [7] 2.3276303 0.6755663 -1.5226688 4.3198444
#>
#> [[3]]
#> [1] -1.8192993 -1.0424239 -2.7118750 -0.8548746 -1.0398695 -1.1856331
#> [7] -0.6406270 -1.9305278 -1.2270034 -1.5044166
#>
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