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] -0.52217763 0.85634859 1.61364375 -0.07646906 0.02335119 -1.04647772
#> [7] -0.36767339 0.27130825 -0.71920820 2.18888897
#>
#> [[2]]
#> [1] -1.994942 4.038914 5.812098 1.088250 1.366680 -2.154807 1.934719
#> [8] -3.015081 5.097321 2.324886
#>
#> [[3]]
#> [1] -1.8624095 -0.2576148 -1.2845500 -1.0881439 -1.3667623 -2.0628164
#> [7] -2.3803015 -0.8288776 -1.1084993 -0.7814033
#>
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