class

LogNormal

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

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

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

p(xμ,σ)=1xσ2πexp ⁣((lnxμ)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 lnX\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

locTensor
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σ21)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,))
>>> (x > 0).all()   # support is strictly positive
Tensor(True)

Methods (7)

dunder

__init__

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

Construct a Log-Normal distribution.

Parameters

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

mean

Tensor
mean: Tensor
source

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
source

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
source

Variance of the Log-Normal distribution.

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

Returns

Tensor

Shape batch_shape.

fn

rsample

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

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.

fn

log_prob

Tensor
log_prob(value: Tensor)
source

Log-probability density of the Log-Normal distribution.

By the change-of-variables formula:

logp(x)=logpN(lnx)lnx\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

entropy

Tensor
entropy()
source

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