feat(distributions): add LogNormal distribution
What does this PR do?
Adds distrax.LogNormal(loc, scale) — the Log-Normal distribution on (0, ∞). If X ~ LogNormal(μ, σ), then log(X) ~ Normal(μ, σ).
The Log-Normal arises naturally in probabilistic ML wherever multiplicative noise is present: financial returns, rainfall, protein expression, and many Bayesian model priors. Unlike Beta/Gamma (bounded or semi-bounded), LogNormal covers the full positive real line with a simple reparameterizable sampler.
Implemented
| Method | Formula |
|---|---|
log_prob(x) |
Normal(μ,σ).log_prob(log x) − log x |
mean() |
exp(μ + σ²/2) |
variance() |
(exp(σ²)−1) · exp(2μ+σ²) |
mode() |
exp(μ − σ²) |
median() |
exp(μ) |
entropy() |
μ + ½ + log(σ) + ½ log(2π) (exact) |
kl_divergence |
Analytic when other is LogNormal (= Normal KL in log-space) |
sample() |
exp(Normal(μ,σ).sample()) — reparameterizable |
Tests
17 tests in log_normal_test.py: log_prob vs TFP and scipy, mean / variance / mode / median / entropy vs TFP, KL divergence (self=0, analytic vs TFP), sample shape, positivity, moments, JIT compatibility.
Friendly bump on this new LogNormal distribution PR, open about a month with no review yet. Happy to adjust anything needed. Thanks!