HalfNormal distribution¶
Story¶
The HalfNormal distribution is a Normal distribution truncated to only have nonzero probability density for values greater than or equal to the location of the peak.
Parameters¶
The HalfNormal distribution is parametrized by a positive scale parameter \(\sigma\) and a location parameter \(\mu\). In most applications, \(\mu = 0\).
Support¶
The HalfNormal distribution is supported on the set of all real numbers that are greater than or equal to \(\mu\), that is on \([\mu, \infty)\).
Probability density function¶
Moments¶
Mean: \(\displaystyle{\mu + \sqrt{\frac{2\sigma^2}{\pi}}}\)
Variance: \(\displaystyle{\left(1  \frac{2}{\pi}\right)\sigma^2}\)
Usage¶
Package 
Syntax 

NumPy 

SciPy 

Stan sampling 

Stan rng 

Notes¶
In Stan, a HalfNormal is defined by putting a lower bound of \(\mu\) on the variable and then using a Normal distribution with location parameter \(\mu\).
The HalfNormal distribution with \(\mu = 0\) is a useful prior for nonnegative parameters that should not be too large and may be very close to zero.