LogNormalDistribution

class LogNormalDistribution(val mu: Double = 0.0, val sigma: Double = 1.0) : ContinuousDistribution(source)

Represents the log-normal distribution.

A random variable follows a log-normal distribution when its natural logarithm is normally distributed. Equivalently, if X is normal then exp(X) is log-normal. This makes the log-normal distribution a natural model for multiplicative processes -- situations where many small random factors combine by multiplication rather than addition. Common examples include stock prices, personal incomes, city populations, and body weights.

The distribution is supported on the interval from zero (exclusive) to positive infinity. It is always right-skewed: small values are common while very large values occur rarely but are not negligible. The parameter mu is the mean of the underlying normal distribution (not the mean of the log-normal itself), and sigma is the standard deviation of the underlying normal distribution (not the standard deviation of the log-normal).

Internally, the CDF, survival function, and quantile function delegate to a NormalDistribution applied to the log-transformed input. Random sampling generates a normal variate and exponentiates it.

Example:

val ln = LogNormalDistribution(mu = 0.0, sigma = 1.0)
ln.pdf(1.0) // 0.3989... (density at x = 1)
ln.cdf(1.0) // 0.5 (median of the standard log-normal)
ln.quantile(0.5) // 1.0 (the median equals exp(mu) when sigma > 0)
ln.mean // 1.6487... (exp(0 + 1/2) for mu=0, sigma=1)
ln.sample(Random(42)) // a single random draw from the distribution

Constructors

Link copied to clipboard
constructor(mu: Double = 0.0, sigma: Double = 1.0)

Properties

Link copied to clipboard
open override val entropy: Double

Returns the Shannon entropy of this distribution in nats.

Link copied to clipboard
open override val kurtosis: Double

Returns the excess kurtosis, which is always positive (heavier tails than a normal distribution).

Link copied to clipboard
open override val mean: Double

Returns the mean of the log-normal distribution, equal to exp(mu + sigma^2 / 2).

Link copied to clipboard
val mu: Double

the mean of the underlying normal distribution (log-scale location). Defaults to 0.0.

Link copied to clipboard

the standard deviation of the underlying normal distribution (log-scale spread). Must be positive. Defaults to 1.0.

Link copied to clipboard
open override val skewness: Double

Returns the skewness, which is always positive (right-skewed).

Link copied to clipboard
open override val variance: Double

Returns the variance of the log-normal distribution.

Functions

Link copied to clipboard
open override fun cdf(x: Double): Double

Returns the cumulative distribution function value at x.

Link copied to clipboard
open override fun logPdf(x: Double): Double

Returns the natural logarithm of the probability density at x.

Link copied to clipboard
open override fun pdf(x: Double): Double

Returns the probability density at x.

Link copied to clipboard
open override fun quantile(p: Double): Double

Returns the quantile (inverse CDF) for the given probability p.

Link copied to clipboard
open override fun sample(random: Random): Double

Draws a single random value from this log-normal distribution.

Link copied to clipboard
open override fun sf(x: Double): Double

Returns the survival function value at x, equal to 1 - cdf(x).