class
HalfNormal
extends
DistributionHalfNormal(scale: Tensor | float, validate_args: bool | None = None)Half-Normal distribution — the absolute value of a zero-mean Normal.
If then . The distribution is supported on and arises naturally as a scale prior in hierarchical Bayesian models (it is weakly informative while keeping probability mass away from zero).
Parameters
scaleTensor | floatScale parameter — the standard deviation of
the underlying zero-mean Normal.
validate_argsbool | None= NoneIf
True, validate parameter constraints at construction time.Attributes
scaleTensorScale parameter .
Notes
PDF:
Log-PDF:
where the right-hand side is the log-density of the full Normal evaluated at .
Moments:
- Mean:
- Variance:
Entropy:
Reparameterised sampling takes abs of a Normal sample, so
gradients flow through unobstructed.
Examples
>>> import lucid
>>> from lucid.distributions import HalfNormal
>>> dist = HalfNormal(scale=1.0)
>>> samples = dist.rsample((300,))
>>> (samples >= 0.0).all()Used by 2
Constructors
1Initialise a HalfNormal distribution.
Parameters
scaleTensor | floatScale parameter — the standard deviation of
the underlying zero-mean Normal distribution.
validate_argsbool | None= NoneIf
True, validate parameter constraints at construction time.Properties
2Instance methods
3Draw reparameterised samples by folding a Normal sample.
Computes abs of a Normal sample, so gradients propagate
through unobstructed.
Parameters
sample_shapetuple[int, ...]= ()Leading shape of the output sample batch.
Returns
TensorNon-negative samples of shape (*sample_shape, *batch_shape).