[Stable]

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 characteristed by a Normal distribution.

dist_lognormal(mu = 0, sigma = 1)

Arguments

mu

The mean (location parameter) of the distribution, which is the mean of the associated Normal distribution. Can be any real number.

sigma

The standard deviation (scale parameter) of the distribution. Can be any positive number.

Details

We recommend reading this documentation on https://pkg.mitchelloharawild.com/distributional/, where the math will render nicely.

In the following, let \(Y\) be a Normal random variable with mean mu = \(\mu\) and standard deviation sigma = \(\sigma\). The log-normal distribution \(X = exp(Y)\) is characterised by:

Support: \(R+\), the set of all real numbers greater than or equal to 0.

Mean: \(e^(\mu + \sigma^2/2\)

Variance: \((e^(\sigma^2)-1) e^(2\mu + \sigma^2\)

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):

The cumulative distribution function has the form

$$ F(x) = \Phi((\ln{x} - \mu)/\sigma) $$

Where \(Phi\) is the CDF of a standard Normal distribution, N(0,1).

See also

Examples

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.784300 2.903319 2.959931 2.552566 2.510658 2.610725 3.096093 3.067839
#>  [9] 3.416986 2.916361
#> 
#> [[2]]
#>  [1] 6.956061 8.187632 7.773666 6.769261 6.881186 6.955320 7.638344 7.110556
#>  [9] 8.905619 7.430703
#> 
#> [[3]]
#>  [1] 15.83861 19.96593 20.95521 23.14503 23.37571 22.09309 19.08908 18.29903
#>  [9] 18.36775 21.54610
#> 
#> [[4]]
#>  [1] 53.00815 56.54926 60.56124 56.17106 51.98723 57.50448 65.62983 60.43908
#>  [9] 57.45739 44.76780
#> 
#> [[5]]
#>  [1] 184.4068 139.4358 163.0398 142.2067 174.5106 144.2022 132.9557 152.9785
#>  [9] 137.7253 139.4327
#> 

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)