Skip to content
class

LogNormal

extendsDistribution
LogNormal(loc: Tensor | float, scale: Tensor | float, validate_args: bool | None = None)

Log-Normal distribution: X=exp⁡(Y)X = \exp(Y) where Y∼N(μ,σ2)Y \sim \mathcal{N}(\mu, \sigma^2).

If a random variable XX has a Log-Normal distribution then its natural logarithm ln⁡X\ln X is Normally distributed. The probability density function is

p(x∣μ,σ)=1x σ2πexp⁡ ⁣(−(ln⁡x−μ)22σ2),x>0p(x \mid \mu, \sigma) = \frac{1}{x\,\sigma\sqrt{2\pi}} \exp\!\left(-\frac{(\ln x - \mu)^2}{2\sigma^2}\right), \quad x > 0

Parameters

locTensor or float
Mean μ\mu of the underlying Normal ln⁡X\ln X.
scaleTensor or float
Standard deviation σ>0\sigma > 0 of the underlying Normal.
validate_argsbool or None= None
Enable constraint validation. Default None.

Attributes

Mean of the latent Normal.
scaleTensor
Standard deviation of the latent Normal.

Notes

The Log-Normal arises naturally whenever a quantity is the product of many independent positive factors (multiplicative growth), just as the Normal arises from additive contributions. Applications include particle-size distributions, financial asset prices, and reaction times.

Mean and variance of X=eYX = e^Y:

E[X]=eμ+σ2/2,Var[X]=(eσ2−1) e2μ+σ2\mathbb{E}[X] = e^{\mu + \sigma^2/2}, \qquad \text{Var}[X] = (e^{\sigma^2} - 1)\,e^{2\mu + \sigma^2}

Note that both grow super-exponentially in σ\sigma.

Mode:

mode(X)=eμ−σ2\text{mode}(X) = e^{\mu - \sigma^2}

The mode is always less than the mean, reflecting right-skewness.

Examples

>>> import lucid.distributions as dist
>>> d = dist.LogNormal(loc=0.0, scale=1.0)
>>> x = d.rsample((100,))
>>> bool((x > 0).all())  # support is strictly positive
True

Used by 3

Constructors

1
dunder

__init__

→None
__init__(loc: Tensor | float, scale: Tensor | float, validate_args: bool | None = None)

Construct a Log-Normal distribution.

Parameters

locTensor or float
Mean of the latent Normal ln⁡X\ln X.
scaleTensor or float
Standard deviation of the latent Normal, σ>0\sigma > 0.
validate_argsbool or None= None
Validate parameter constraints on construction.

Properties

3
prop

mean

→Tensor
mean: Tensor

Mean of the Log-Normal distribution.

E[X]=eμ+σ2/2\mathbb{E}[X] = e^{\mu + \sigma^2/2}

Returns

Tensor

Shape batch_shape.

prop

mode

→Tensor
mode: Tensor

Mode of the Log-Normal distribution.

mode(X)=eμ−σ2\text{mode}(X) = e^{\mu - \sigma^2}

The mode is strictly less than the mean, reflecting the right-skewed nature of the distribution.

Returns

Tensor

Shape batch_shape.

prop

variance

→Tensor
variance: Tensor

Variance of the Log-Normal distribution.

Var[X]=(eσ2−1) e2μ+σ2\text{Var}[X] = (e^{\sigma^2} - 1)\,e^{2\mu + \sigma^2}

Returns

Tensor

Shape batch_shape.

Instance methods

6
fn

cdf

→Tensor
cdf(value: Tensor)

Cumulative distribution function of the Log-Normal distribution.

F(x)=Φ ⁣(ln⁡x−μσ),x>0F(x) = \Phi\!\left(\frac{\ln x - \mu}{\sigma}\right), \quad x > 0

The latent Normal's CDF at ln⁡x\ln x; 0 at and below 0.

Returns probabilities in [0,1][0, 1].

Examples

>>> LogNormal(0.0, 1.0).cdf(lucid.tensor(1.0))  # the median is e^mu
tensor(0.5)
fn

entropy

→Tensor
entropy()

Shannon differential entropy of the Log-Normal distribution.

H[X]=μ+H[N(0,σ2)]=μ+12+12ln⁡(2π)+ln⁡σH[X] = \mu + H[\mathcal{N}(0,\sigma^2)] = \mu + \frac{1}{2} + \frac{1}{2}\ln(2\pi) + \ln\sigma

where the extra μ\mu term accounts for the Jacobian of the exponential transformation.

Returns

Tensor

Entropy values of shape batch_shape (in nats).

fn

expand

→Self
expand(batch_shape: Sequence[int], _instance: Self | None = None)

Return a new LogNormal with batch dimensions expanded to batch_shape.

fn

icdf

→Tensor
icdf(value: Tensor)

Quantile function of the Log-Normal distribution.

Q(p)=exp⁡ ⁣(μ+σΦ−1(p))Q(p) = \exp\!\left(\mu + \sigma \Phi^{-1}(p)\right)

Returns quantiles in [0,∞][0, \infty].

Examples

>>> LogNormal(0.0, 1.0).icdf(lucid.tensor(0.5))
tensor(1.)
fn

log_prob

→Tensor
log_prob(value: Tensor)

Log-probability density of the Log-Normal distribution.

By the change-of-variables formula:

log⁡p(x)=log⁡pN(ln⁡x)−ln⁡x\log p(x) = \log p_{\mathcal{N}}(\ln x) - \ln x

where pNp_{\mathcal{N}} is the density of the underlying Normal distribution.

Parameters

valueTensor
Strictly positive observation(s) x>0x > 0.

Returns

Tensor

Log-density at value.

fn

rsample

→Tensor
rsample(sample_shape: tuple[int, ...] = ())

Draw reparameterised samples.

Samples are obtained by exponentiating Normal samples from the underlying Normal base distribution:

X=exp⁡(μ+σε),ε∼N(0,1)X = \exp(\mu + \sigma \varepsilon), \quad \varepsilon \sim \mathcal{N}(0,1)

Parameters

sample_shapetuple[int, ...]= ()
Shape prefix for the batch of samples.

Returns

Tensor

Strictly positive samples of shape sample_shape + batch_shape.