15.1 Normal Distribution

15.1.1 Probability Density Function

If \(\mu \in \mathbb{R}\) and \(\sigma \in \mathbb{R}^+\), then for \(y \in \mathbb{R}\), \[ \text{Normal}(y|\mu,\sigma) = \frac{1}{\sqrt{2 \pi} \ \sigma} \exp\left( - \, \frac{1}{2} \left( \frac{y - \mu}{\sigma} \right)^2 \right) \!. \]

15.1.2 Sampling Statement

y ~ normal(mu, sigma)

Increment target log probability density with normal_lpdf( y | mu, sigma) dropping constant additive terms.

15.1.3 Stan Functions

real normal_lpdf(reals y | reals mu, reals sigma)
The log of the normal density of y given location mu and scale sigma

real normal_cdf(reals y, reals mu, reals sigma)
The cumulative normal distribution of y given location mu and scale sigma; normal_cdf will underflow to 0 for \(\frac{{y}-{\mu}}{{\sigma}}\) below -37.5 and overflow to 1 for \(\frac{{y}-{\mu}}{{\sigma}}\) above 8.25; the function Phi_approx is more robust in the tails, but must be scaled and translated for anything other than a standard normal.

real normal_lcdf(reals y | reals mu, reals sigma)
The log of the cumulative normal distribution of y given location mu and scale sigma; normal_lcdf will underflow to \(-\infty\) for \(\frac{{y}-{\mu}}{{\sigma}}\) below -37.5 and overflow to 0 for \(\frac{{y}-{\mu}}{{\sigma}}\) above 8.25; see above for discussion of Phi_approx as an alternative.

real normal_lccdf(reals y | reals mu, reals sigma)
The log of the complementary cumulative normal distribution of y given location mu and scale sigma; normal_lccdf will overflow to 0 for \(\frac{{y}-{\mu}}{{\sigma}}\) below -37.5 and underflow to \(-\infty\) for \(\frac{{y}-{\mu}}{{\sigma}}\) above 8.25; see above for discussion of Phi_approx as an alternative.

R normal_rng(reals mu, reals sigma)
Generate a normal variate with location mu and scale sigma; may only be used in generated quantities block. For a description of argument and return types, see section 10.8.3.

15.1.4 Standard Normal Distribution

The standard normal distribution is so-called because its parameters are the units for their respective operations—the location (mean) is zero and the scale (standard deviation) one. The standard normal is parameter free and the unit parameters allow considerable simplification of the expression for the density. \[ \text{StdNormal}(y) \ = \ \text{Normal}(y \mid 0, 1) \ = \ \frac{1}{\sqrt{2 \pi}} \, \exp \left( \frac{-y^2}{2} \right)\!. \] Up to a proportion on the log scale, where Stan computes, \[ \log \text{Normal}(y \mid 0, 1) \ = \ \frac{-y^2}{2} + \text{const}. \] With no logarithm, no subtraction, and no division by a parameter, the standard normal log density is much more efficient to compute than the normal log density with constant location \(0\) and scale \(1\).

15.1.5 Stan Functions

Only the log probabilty density function is available for the standard normal distribution; for other functions, use the normal_ versions with parameters \(\mu = 0\) and \(\sigma = 1\).

real std_normal_lpdf(reals y)
The standard normal (location zero, scale one) log probability density of y.

15.1.6 Sampling Statement

y ~ std_normal(\pitemTwo{y)

Increment target log probability density with std_normal_lpdf( y | \pitemTwo{y) dropping constant additive terms.