Half-Normal distribution


Story

The Half-Normal 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 Half-Normal distribution is parametrized by a positive scale parameter \(\sigma\) and a location parameter \(\mu\). In most applications, \(\mu = 0\).


Support

The Half-Normal 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

\[\begin{split} \begin{align} f(y;\mu, \sigma) = \left\{\begin{array}{cll} \sqrt{\frac{2}{\pi\sigma^2}}\,\mathrm{e}^{-(y-\mu)^2/2\sigma^2} & & y \ge \mu \\[1em] 0 & & \text{otherwise}. \end{array}\right. \end{align}\end{split}\]

Moments

Mean: \(\displaystyle{\mu + \sqrt{\frac{2\sigma^2}{\pi}}}\)

Variance: \(\displaystyle{\left(1 - \frac{2}{\pi}\right)\sigma^2}\)


Usage

Package

Syntax

NumPy

mu + np.abs(rg.normal(0, sigma)

SciPy

scipy.stats.halfnorm(mu, sigma)

Stan sampling

real<lower=mu> y; y ~ normal(mu, sigma)

Stan rng

real<lower=mu> y; y = mu + abs(normal_rng(0, sigma))



Notes

  • In Stan, a Half-Normal is defined by putting a lower bound of \(\mu\) on the variable and then using a Normal distribution with location parameter \(\mu\).

  • The Half-Normal distribution with \(\mu = 0\) is a useful prior for nonnegative parameters that should not be too large and may be very close to zero.


PDF and CDF plots