1% File src/library/stats/man/Lognormal.Rd 2% Part of the R package, https://www.R-project.org 3% Copyright 1995-2014 R Core Team 4% Distributed under GPL 2 or later 5 6\name{Lognormal} 7\alias{Lognormal} 8\alias{dlnorm} 9\alias{plnorm} 10\alias{qlnorm} 11\alias{rlnorm} 12\title{The Log Normal Distribution} 13\description{ 14 Density, distribution function, quantile function and random 15 generation for the log normal distribution whose logarithm has mean 16 equal to \code{meanlog} and standard deviation equal to \code{sdlog}. 17} 18\usage{ 19dlnorm(x, meanlog = 0, sdlog = 1, log = FALSE) 20plnorm(q, meanlog = 0, sdlog = 1, lower.tail = TRUE, log.p = FALSE) 21qlnorm(p, meanlog = 0, sdlog = 1, lower.tail = TRUE, log.p = FALSE) 22rlnorm(n, meanlog = 0, sdlog = 1) 23} 24\arguments{ 25 \item{x, q}{vector of quantiles.} 26 \item{p}{vector of probabilities.} 27 \item{n}{number of observations. If \code{length(n) > 1}, the length 28 is taken to be the number required.} 29 \item{meanlog, sdlog}{mean and standard deviation of the distribution 30 on the log scale with default values of \code{0} and \code{1} respectively.} 31 \item{log, log.p}{logical; if TRUE, probabilities p are given as log(p).} 32 \item{lower.tail}{logical; if TRUE (default), probabilities are 33 \eqn{P[X \le x]}, otherwise, \eqn{P[X > x]}.} 34} 35\value{ 36 \code{dlnorm} gives the density, 37 \code{plnorm} gives the distribution function, 38 \code{qlnorm} gives the quantile function, and 39 \code{rlnorm} generates random deviates. 40 41 The length of the result is determined by \code{n} for 42 \code{rlnorm}, and is the maximum of the lengths of the 43 numerical arguments for the other functions. 44 45 The numerical arguments other than \code{n} are recycled to the 46 length of the result. Only the first elements of the logical 47 arguments are used. 48} 49\source{ 50 \code{dlnorm} is calculated from the definition (in \sQuote{Details}). 51 \code{[pqr]lnorm} are based on the relationship to the normal. 52 53 Consequently, they model a single point mass at \code{exp(meanlog)} 54 for the boundary case \code{sdlog = 0}. 55} 56\details{ 57 The log normal distribution has density 58 \deqn{ 59 f(x) = \frac{1}{\sqrt{2\pi}\sigma x} e^{-(\log(x) - \mu)^2/2 \sigma^2}% 60 }{f(x) = 1/(\sqrt(2 \pi) \sigma x) e^-((log x - \mu)^2 / (2 \sigma^2))} 61 where \eqn{\mu} and \eqn{\sigma} are the mean and standard 62 deviation of the logarithm. 63 The mean is \eqn{E(X) = exp(\mu + 1/2 \sigma^2)}, 64 the median is \eqn{med(X) = exp(\mu)}, and the variance 65 \eqn{Var(X) = exp(2\mu + \sigma^2)(exp(\sigma^2) - 1)}{Var(X) = exp(2*\mu + \sigma^2)*(exp(\sigma^2) - 1)} 66 and hence the coefficient of variation is 67 \eqn{\sqrt{exp(\sigma^2) - 1}}{sqrt(exp(\sigma^2) - 1)} which is 68 approximately \eqn{\sigma} when that is small (e.g., \eqn{\sigma < 1/2}). 69} 70%% Mode = exp(max(0, mu - sigma^2)) 71\note{ 72 The cumulative hazard \eqn{H(t) = - \log(1 - F(t))}{H(t) = - log(1 - F(t))} 73 is \code{-plnorm(t, r, lower = FALSE, log = TRUE)}. 74} 75\references{ 76 Becker, R. A., Chambers, J. M. and Wilks, A. R. (1988) 77 \emph{The New S Language}. 78 Wadsworth & Brooks/Cole. 79 80 Johnson, N. L., Kotz, S. and Balakrishnan, N. (1995) 81 \emph{Continuous Univariate Distributions}, volume 1, chapter 14. 82 Wiley, New York. 83} 84\seealso{ 85 \link{Distributions} for other standard distributions, including 86 \code{\link{dnorm}} for the normal distribution. 87} 88\examples{ 89dlnorm(1) == dnorm(0) 90} 91\keyword{distribution} 92