This is an old version, view current version.
12.3 Sampling notation
The notation
y ~ normal(mu, sigma);
provides the same (proportional) contribution to the model log density as the explicit target density increment,
target += normal_lpdf(y | mu, sigma);
In both cases, the effect is to add terms to the target log density.
The only difference is that the example with the sampling (~
)
notation drops all additive constants in the log density; the
constants are not necessary for any of Stan’s sampling, approximation,
or optimization algorithms.