19.1 Normal distribution
19.1.1 Probability density function
If μ∈R and σ∈R+, then for y∈R, Normal(y|μ,σ)=1√2π σexp(−12(y−μσ)2).
19.1.2 Sampling statement
y ~
normal
(mu, sigma)
Increment target log probability density with normal_lupdf(y | mu, sigma)
.
Available since 2.0
19.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
Available since 2.12
real
normal_lupdf
(reals y | reals mu, reals sigma)
The log of the normal density of y given location mu and scale sigma dropping
constant additive terms.
Available since 2.25
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 y−μσ
below -37.5 and overflow to 1 for y−μσ 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.
Available since 2.0
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 −∞ for
y−μσ below -37.5 and overflow to 0 for
y−μσ above 8.25; log(Phi_approx(...))
is more
robust in the tails, but must be scaled and translated for anything other
than a standard normal.
Available since 2.12
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
y−μσ below -37.5 and underflow to −∞
for y−μσ above 8.25; log1m(Phi_approx(...))
is
more robust in the tails, but must be scaled and translated for anything
other than a standard normal.
Available since 2.15
R
normal_rng
(reals mu, reals sigma)
Generate a normal variate with location mu and scale sigma; may only
be used in transformed data and generated quantities blocks.
For a description of argument and return types, see section
vectorized PRNG functions.
Available since 2.18
19.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. StdNormal(y) = Normal(y∣0,1) = 1√2πexp(−y22). Up to a proportion on the log scale, where Stan computes, logNormal(y∣0,1) = −y22+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.
19.1.5 Sampling statement
y ~
std_normal
()
Increment target log probability density with std_normal_lupdf(y)
.
Available since 2.19
19.1.6 Stan functions
real
std_normal_lpdf
(reals y)
The standard normal (location zero, scale one) log probability density
of y.
Available since 2.18
real
std_normal_lupdf
(reals y)
The standard normal (location zero, scale one) log probability density
of y dropping constant additive terms.
Available since 2.25
real
std_normal_cdf
(reals y)
The cumulative standard normal distribution of y; std_normal_cdf will
underflow to 0 for y below -37.5 and overflow to 1 for y above 8.25;
the function Phi_approx
is more robust in the tails.
Available since 2.21
real
std_normal_lcdf
(reals y)
The log of the cumulative standard normal distribution of y; std_normal_lcdf
will underflow to −∞ for y below -37.5 and overflow to 0 for y
above 8.25; log(Phi_approx(...))
is more robust in the tails.
Available since 2.21
real
std_normal_lccdf
(reals y)
The log of the complementary cumulative standard normal distribution of y;
std_normal_lccdf will overflow to 0 for y below -37.5 and underflow to
−∞ for y above 8.25; log1m(Phi_approx(...))
is more robust in the
tails.
Available since 2.21
R
std_normal_qf
(T x)
Returns the value of the inverse standard normal cdf Φ−1 at the
specified quantile x
. The std_normal_qf
is equivalent to the
inv_Phi
function.
Available since 2.31
R
std_normal_log_qf
(T x)
Return the value of the inverse standard normal cdf Φ−1 evaluated
at the log of the specified quantile x
. This function is equivalent to
std_normal_qf(exp(x))
but is more numerically stable.
Available since 2.31
real
std_normal_rng
()
Generate a normal variate with location zero and scale one; may only
be used in transformed data and generated quantities blocks.
Available since 2.21