HalfNormal
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 | floatvalidate_argsbool | None= NoneTrue, validate parameter constraints at construction time.Attributes
scaleTensorNotes
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,))
>>> bool((samples >= 0.0).all())
TrueUsed by 2
Constructors
1Initialise a HalfNormal distribution.
Parameters
scaleTensor | floatvalidate_argsbool | None= NoneTrue, validate parameter constraints at construction time.Properties
3Instance methods
5Cumulative distribution function of the half-Normal distribution.
Returns probabilities in ; 0 below 0.
Examples
>>> HalfNormal(scale=1.0).cdf(lucid.tensor(1.0))
tensor(0.6827)Quantile function of the half-Normal distribution.
Returns quantiles in .
Examples
>>> HalfNormal(scale=1.0).icdf(lucid.tensor(0.5))
tensor(0.6745)Draw reparameterised samples by folding a Normal sample.
Computes abs of a Normal sample, so gradients propagate
through unobstructed.
Parameters
sample_shapetuple[int, ...]= ()Returns
TensorNon-negative samples of shape (*sample_shape, *batch_shape).