# Half-Cauchy distribution¶

## Story¶

The Half-Cauchy distribution is a Cauchy distribution truncated to only have nonzero probability density for values greater than or equal to the location of the peak.

## Parameters¶

The Half-Cauchy distribution has a location parameter $$\mu$$, which may take on any real value, though $$\mu = 0$$ for most applications. The peak’s width is dictated by a positive scale parameter $$\sigma$$.

## Support¶

The Half-Cauchy 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} \frac{2}{\pi \sigma}\,\frac{1}{1 + (y-\mu)^2/\sigma^2} & & y \ge \mu \\[1em] 0 & & \text{otherwise}. \end{array}\right. \end{align}\end{split}

## Moments¶

Mean: Undefined

Variance: Undefined

## Usage¶

Package

Syntax

NumPy

mu + np.abs(sigma * rg.standard_cauchy())

SciPy

scipy.stats.halfcauchy(mu, sigma)

Stan sampling

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

Stan rng

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

## Notes¶

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

• The Half-Cauchy distribution with $$\mu = 0$$ is a useful prior for nonnegative parameters that may be very large, as allowed by the very heavy tails of the Half-Cauchy distribution.