Density, distribution function, quantile function and random
generation for the log normal distribution whose logarithm has mean
equal to meanlog and standard deviation equal to sdlog.
Source
dlnorm is calculated from the definition (in ‘Details’).
[pqr]lnorm are based on the relationship to the normal.
Consequently, they model a single point mass at exp(meanlog)
for the boundary case sdlog = 0.
Value
dlnorm gives the density,
plnorm gives the distribution function,
qlnorm gives the quantile function, and
rlnorm generates random deviates.
The length of the result is determined by n for
rlnorm, and is the maximum of the lengths of the
numerical arguments for the other functions.
The numerical arguments other than n are recycled to the
length of the result. Only the first elements of the logical
arguments are used.
Details
The log normal distribution has density $$ f(x) = \frac{1}{\sqrt{2\pi}\sigma x} e^{-(\log(x) - \mu)^2/2 \sigma^2}% $$ where \(\mu\) and \(\sigma\) are the mean and standard deviation of the logarithm. The mean is \(E(X) = exp(\mu + 1/2 \sigma^2)\), the median is \(med(X) = exp(\mu)\), and the variance \(Var(X) = exp(2\mu + \sigma^2)(exp(\sigma^2) - 1)\) and hence the coefficient of variation is \(\sqrt{exp(\sigma^2) - 1}\) which is approximately \(\sigma\) when that is small (e.g., \(\sigma < 1/2\)).
References
Becker, R. A., Chambers, J. M. and Wilks, A. R. (1988) The New S Language. Wadsworth & Brooks/Cole.
Johnson, N. L., Kotz, S. and Balakrishnan, N. (1995) Continuous Univariate Distributions, volume 1, chapter 14. Wiley, New York.
See also
Distributions for other standard distributions, including
dnorm for the normal distribution.
Examples
dlnorm2(seq(0,4,0.25), 2, 1)
#> [1] 0.0000000000 0.0005757428 0.0442991085 0.2071346586 0.3958009702
#> [6] 0.5066252419 0.5252248069 0.4820705272 0.4106521947 0.3336148024
#> [11] 0.2628174046 0.2029235657 0.1546511354 0.1168989116 0.0879351969
#> [16] 0.0659844844 0.0494751213