Laplace
DistributionLaplace(loc: Tensor | float, scale: Tensor | float, validate_args: bool | None = None)Laplace (double-exponential) distribution on .
Symmetric continuous distribution composed of two mirrored Exponential densities placed back-to-back at the location . It is the maximum-entropy distribution with a given mean and a given mean absolute deviation, and is the prior whose negative log-density induces the L1 (Lasso) penalty.
Parameters
Notes
Probability density:
Moments:
The Laplace has heavier tails than the Normal: its kurtosis is 6 vs. 3 for the Normal, and its tails decay exponentially rather than quadratically in log-space.
Sampling uses the closed-form inverse CDF:
so rsample is exact and gradient-friendly through both
and .
Examples
>>> import lucid
>>> from lucid.distributions import Laplace
>>> d = Laplace(loc=0.0, scale=1.0)
>>> d.mean
Tensor(0.0)
>>> d.rsample((4,))
Tensor([...])
>>> d.log_prob(lucid.tensor(0.0))
Tensor(-0.6931)Used by 2
Constructors
1__init__
→None__init__(loc: Tensor | float, scale: Tensor | float, validate_args: bool | None = None)Construct a Laplace distribution.
Parameters
Notes
The Laplace distribution has PDF:
It is also called the double-exponential distribution because it resembles two mirrored Exponential densities placed back-to-back at the location . It is frequently used in robust statistics and as the prior inducing L1 (Lasso) regularisation.
Examples
>>> from lucid.distributions import Laplace
>>> d = Laplace(loc=0.0, scale=1.0)
>>> d.mean
Tensor(0.0)Properties
2Instance methods
4Shannon entropy of the Laplace distribution (in nats).
Returns
TensorEntropy in nats, shape batch_shape.
Examples
>>> Laplace(loc=0.0, scale=1.0).entropy() # 1 + log(2) ≈ 1.693
Tensor(1.6931)Reparameterised sample via the inverse-CDF method.
Uses the closed-form quantile function:
where and . Gradients flow through both and .
Parameters
sample_shapetuple[int, ...]= ()().Returns
TensorReparameterised samples of shape sample_shape + batch_shape.
Examples
>>> d = Laplace(loc=0.0, scale=1.0)
>>> x = d.rsample((200,))