# Truncated normal distribution

(Redirected from Truncated Gaussian distribution)
Notation Probability density function Probability density function for the truncated normal distribution for different sets of parameters. In all cases, a = −10 and b = 10. For the black: μ = −8, σ = 2; blue: μ = 0, σ = 2; red: μ = 9, σ = 10; orange: μ = 0, σ = 10. Cumulative distribution function Cumulative distribution function for the truncated normal distribution for different sets of parameters. In all cases, a = −10 and b = 10. For the black: μ = −8, σ = 2; blue: μ = 0, σ = 2; red: μ = 9, σ = 10; orange: μ = 0, σ = 10. ${\displaystyle \xi ={\frac {x-\mu }{\sigma }},\ \alpha ={\frac {a-\mu }{\sigma }},\ \beta ={\frac {b-\mu }{\sigma }}}$ ${\displaystyle Z=\Phi (\beta )-\Phi (\alpha )}$ μ ∈ R σ2 ≥ 0 a ∈ R — minimum value of x b ∈ R — maximum value of x (b > a) x ∈ [a,b] ${\displaystyle f(x;\mu ,\sigma ,a,b)={\frac {\phi (\xi )}{\sigma Z}}\,}$[1] ${\displaystyle F(x;\mu ,\sigma ,a,b)={\frac {\Phi (\xi )-\Phi (\alpha )}{Z}}}$ ${\displaystyle \mu +{\frac {\phi (\alpha )-\phi (\beta )}{Z}}\sigma }$ ${\displaystyle \mu +\Phi ^{-1}\left({\frac {\Phi (\alpha )+\Phi (\beta )}{2}}\right)\sigma }$ ${\displaystyle \left\{{\begin{array}{ll}a,&\mathrm {if} \ \mu b\end{array}}\right.}$ ${\displaystyle \sigma ^{2}\left[1+{\frac {\alpha \phi (\alpha )-\beta \phi (\beta )}{Z}}-\left({\frac {\phi (\alpha )-\phi (\beta )}{Z}}\right)^{2}\right]}$ ${\displaystyle \ln({\sqrt {2\pi e}}\sigma Z)+{\frac {\alpha \phi (\alpha )-\beta \phi (\beta )}{2Z}}}$ ${\displaystyle e^{\mu t+\sigma ^{2}t^{2}/2}\left[{\frac {\Phi (\beta -\sigma t)-\Phi (\alpha -\sigma t)}{\Phi (\beta )-\Phi (\alpha )}}\right]}$

In probability and statistics, the truncated normal distribution is the probability distribution derived from that of a normally distributed random variable by bounding the random variable from either below or above (or both). The truncated normal distribution has wide applications in statistics and econometrics. For example, it is used to model the probabilities of the binary outcomes in the probit model and to model censored data in the Tobit model.

## Definition

Suppose ${\displaystyle X\sim N(\mu ,\sigma ^{2})}$ has a normal distribution and lies within the interval ${\displaystyle X\in (a,b),\;-\infty \leq a. Then ${\displaystyle X}$ conditional on ${\displaystyle a has a truncated normal distribution.

Its probability density function, ${\displaystyle f}$, for ${\displaystyle a\leq x\leq b}$, is given by

${\displaystyle f(x;\mu ,\sigma ,a,b)={\frac {\phi ({\frac {x-\mu }{\sigma }})}{\sigma \left(\Phi ({\frac {b-\mu }{\sigma }})-\Phi ({\frac {a-\mu }{\sigma }})\right)}}}$

and by ${\displaystyle f=0}$ otherwise.

Here,

${\displaystyle \phi (\xi )={\frac {1}{\sqrt {2\pi }}}\exp \left(-{\frac {1}{2}}\xi ^{2}\right)}$

is the probability density function of the standard normal distribution and ${\displaystyle \Phi (\cdot )}$ is its cumulative distribution function

${\displaystyle \Phi (x)={\frac {1}{2}}\left(1+\operatorname {erf} (x/{\sqrt {2}})\right).}$

By definition, if ${\displaystyle b=\infty }$, then ${\displaystyle \Phi \left({\tfrac {b-\mu }{\sigma }}\right)=1}$, and similarly, if ${\displaystyle a=-\infty }$, then ${\displaystyle \Phi \left({\tfrac {a-\mu }{\sigma }}\right)=0}$.

## Moments

If the random variable has been truncated only from below, some probability mass has been shifted to higher values, giving a first-order stochastically dominating distribution and hence increasing the mean to a value higher than the mean ${\displaystyle \mu }$ of the original normal distribution. Likewise, if the random variable has been truncated only from above, the truncated distribution has a mean less than ${\displaystyle \mu .}$

Regardless of whether the random variable is bounded above, below, or both, the truncation is a mean-preserving contraction combined with a mean-changing rigid shift, and hence the variance of the truncated distribution is less than the variance ${\displaystyle \sigma ^{2}}$ of the original normal distribution.

Let ${\displaystyle \alpha =(a-\mu )/\sigma }$ and ${\displaystyle \beta =(b-\mu )/\sigma :}$

Two sided truncation
[2]
${\displaystyle \operatorname {E} (X\mid a
${\displaystyle \operatorname {Var} (X\mid a
One sided truncation (of lower tail)
[3]

In this case ${\displaystyle \;\phi (\beta )=0,\;\Phi (\beta )=1,}$ and

${\displaystyle \operatorname {E} (X\mid X>a)=\mu +\sigma \phi (\alpha )/Z,\!}$
${\displaystyle \operatorname {Var} (X\mid X>a)=\sigma ^{2}[1+\alpha \phi (\alpha )/Z-(\phi (\alpha )/Z)^{2}],}$

where ${\displaystyle Z=1-\Phi (\alpha ).}$

One sided truncation (of upper tail)
${\displaystyle \operatorname {E} (X\mid X
${\displaystyle \operatorname {Var} (X\mid X

Barr and Sherrill (1999) give a simpler expression for the variance of one sided truncations. Their formula is in terms of the chi-square CDF, which is implemented in standard software libraries. Bebu and Mathew (2009) provide formulas for (generalized) confidence intervals around the truncated moments.

Differential equation

${\displaystyle \left\{\sigma ^{2}f'(x)+f(x)(x-\mu )=0,f(0)={\frac {{\sqrt {\frac {2}{\pi }}}e^{-{\frac {\mu ^{2}}{2\sigma ^{2}}}}}{\sigma \left({\text{erf}}\left({\frac {\mu -a}{{\sqrt {2}}\sigma }}\right)-{\text{erf}}\left({\frac {\mu -b}{{\sqrt {2}}\sigma }}\right)\right)}}\right\}}$

A recursive formula

As for the non-truncated case, there is a neat recursive formula for the truncated moments. See Orjebin.[4]

## Simulating

A random variate x defined as ${\displaystyle x=\Phi ^{-1}(\Phi (\alpha )+U\cdot (\Phi (\beta )-\Phi (\alpha )))\sigma +\mu }$ with ${\displaystyle \Phi }$ the cumulative distribution function and ${\displaystyle \Phi ^{-1}}$ its inverse, ${\displaystyle U}$ a uniform random number on ${\displaystyle (0,1)}$, follows the distribution truncated to the range ${\displaystyle (a,b)}$. This is simply the inverse transform method for simulating random variables. Although one of the simplest, this method can either fail when sampling in the tail of the normal distribution,[5] or be much too slow.[6] Thus, in practice, one has to find alternative methods of simulation.

One such truncated normal generator (implemented in Matlab and in R (programming language) as trandn.R ) is based on an acceptance rejection idea due to Marsaglia.[7] Despite the slightly suboptimal acceptance rate of Marsaglia (1964) in comparison with Robert (1995), Marsaglia's method is typically faster,[6] because it does not require the costly numerical evaluation of the exponential function.

For more on simulating a draw from the truncated normal distribution, see Robert (1995), Lynch (2007) Section 8.1.3 (pages 200–206), Devroye (1986). The MSM package in R has a function, rtnorm, that calculates draws from a truncated normal. The truncnorm package in R also has functions to draw from a truncated normal.

Chopin (2011) proposed (arXiv) an algorithm inspired from the Ziggurat algorithm of Marsaglia and Tsang (1984, 2000), which is usually considered as the fastest Gaussian sampler, and is also very close to Ahrens’s algorithm (1995). Implementations can be found in C, C++, Matlab and Python.

Sampling from the multivariate truncated normal distribution is considerably more difficult.[8] Exact or perfect simulation is only feasible in the case of truncation of the normal distribution to a polytope region.[8] In more general cases, Damien and Walker (2001) introduce a general methodology for sampling truncated densities within a Gibbs sampling framework. Their algorithm introduces one latent variable and, within a Gibbs sampling framework, it is more computationally efficient than the algorithm of Robert (1995).