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{align} f(y;\mu, \sigma) = \sqrt{\frac{2}{\pi\sigma^2}}\,\mathrm{e}^{-(y-\mu)^2/2\sigma^2}. \end{align}\]

Note that the distribution is only supported for \(y \ge \mu\).


Cumulative distribution function

\[\begin{split}\begin{align} F(y;\mu, \sigma) = \left\{\begin{array}{cll} \displaystyle{\text{erf}\left(\frac{y - \mu}{\sigma\sqrt{2}}\right)} & & y \ge \mu,\\[0.5em] 0 & & \text{otherwise}, \end{array} \right. \end{align}\end{split}\]

where \(\text{erf}(x)\) denotes the error 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

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

SciPy

scipy.stats.halfnorm(mu, sigma)

Distributions.jl

truncated(Normal(mu, sigma); lower=mu)

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