The log-normal distribution is a commonly used transformation of the Normal distribution. If \(X\) follows a log-normal distribution, then \(\ln{X}\) would be characterised by a Normal distribution.
dist_lognormal(mu = 0, sigma = 1)We recommend reading this documentation on pkgdown which renders math nicely. https://pkg.mitchelloharawild.com/distributional/reference/dist_lognormal.html
In the following, let \(X\) be a log-normal random variable with
mu = \(\mu\) and sigma = \(\sigma\).
Support: \(R^+\), the set of positive real numbers.
Mean: \(e^{\mu + \sigma^2/2}\)
Variance: \((e^{\sigma^2} - 1) e^{2\mu + \sigma^2}\)
Skewness: \((e^{\sigma^2} + 2) \sqrt{e^{\sigma^2} - 1}\)
Excess Kurtosis: \(e^{4\sigma^2} + 2 e^{3\sigma^2} + 3 e^{2\sigma^2} - 6\)
Probability density function (p.d.f):
$$ f(x) = \frac{1}{x\sqrt{2 \pi \sigma^2}} e^{-(\ln{x} - \mu)^2 / (2 \sigma^2)} $$
Cumulative distribution function (c.d.f):
$$ F(x) = \Phi\left(\frac{\ln{x} - \mu}{\sigma}\right) $$
where \(\Phi\) is the c.d.f. of the standard Normal distribution.
Moment generating function (m.g.f):
Does not exist in closed form.
dist <- dist_lognormal(mu = 1:5, sigma = 0.1)
dist
#> <distribution[5]>
#> [1] lN(1, 0.01) lN(2, 0.01) lN(3, 0.01) lN(4, 0.01) lN(5, 0.01)
mean(dist)
#> [1] 2.731907 7.426094 20.186216 54.871824 149.157083
variance(dist)
#> [1] 0.07500759 0.55423526 4.09527545 30.26022006 223.59446360
skewness(dist)
#> [1] 0.3017591 0.3017591 0.3017591 0.3017591 0.3017591
kurtosis(dist)
#> [1] 0.1623239 0.1623239 0.1623239 0.1623239 0.1623239
generate(dist, 10)
#> [[1]]
#> [1] 2.268372 2.479770 2.808937 2.772599 2.424468 2.700803 2.531545 2.237002
#> [9] 2.802470 2.337099
#>
#> [[2]]
#> [1] 7.036684 8.971989 7.454462 7.048715 7.657213 9.429064 8.038234 8.035449
#> [9] 7.258841 7.143602
#>
#> [[3]]
#> [1] 24.24908 19.85483 18.04264 20.43742 21.33054 20.28091 19.40403 20.84049
#> [9] 17.22014 15.53991
#>
#> [[4]]
#> [1] 57.09642 52.17184 54.26868 51.47233 55.98393 55.31401 55.75467 48.11861
#> [9] 51.09322 52.22699
#>
#> [[5]]
#> [1] 139.9108 141.0417 143.7527 163.0416 156.7406 162.1838 140.0949 139.0415
#> [9] 157.3752 126.5862
#>
density(dist, 2)
#> [1] 1.799910e-02 1.637111e-37 5.539330e-116 6.972494e-238 0.000000e+00
density(dist, 2, log = TRUE)
#> [1] -4.017433 -84.702715 -265.387997 -546.073279 -926.758561
cdf(dist, 4)
#> [1] 9.999440e-01 4.203228e-10 7.003186e-59 6.915322e-151 2.970982e-286
quantile(dist, 0.7)
#> [1] 2.864632 7.786878 21.166930 57.537681 156.403632
# A log-normal distribution X is exp(Y), where Y is a Normal distribution of
# the same parameters. So log(X) will produce the Normal distribution Y.
log(dist)
#> <distribution[5]>
#> [1] N(1, 0.01) N(2, 0.01) N(3, 0.01) N(4, 0.01) N(5, 0.01)