@@ -58,39 +58,36 @@ In BUGS, statements are executed according to the directed graphical
5858model so that variables are always defined when needed. A side effect
5959of the direct execution of Stan's modeling language is that statements
6060execute in the order in which they are written. For instance, the
61- following Stan program, which sets ` mu ` before using it to sample ` y ` .
61+ following Stan program, which sets ` mu ` before using it to sample ` y ` :
6262
6363```
6464mu = a + b * x;
65- y ~ normal(mu,sigma);
65+ y ~ normal(mu, sigma);
6666```
67-
68- It translates to the following C++ code.
67+ translates to the following C++ code:
6968
7069```
7170mu = a + b * x;
72- lp += normal_log( mu,sigma);
71+ target += normal_lpdf(y | mu, sigma);
7372```
7473
75- Contrast this with the Stan program
74+ Contrast this with the following Stan program:
7675
7776```
78- y ~ normal(mu,sigma)
79- mu = a + b * x
77+ y ~ normal(mu, sigma);
78+ mu = a + b * x;
8079```
8180
8281This program is well formed, but is almost certainly
8382a coding error, because it attempts to use ` mu ` before
84- it is set. It translates to the following C++ code.
83+ it is set. The direct translation to C++ code
84+ highlights the potential error of using ` mu ` in the first
85+ statement:
8586```
86- lp += normal_log( mu,sigma);
87+ target += normal_lpdf(y | mu, sigma);
8788mu = a + b * x;
8889```
8990
90- The direct translation to the imperative language of C++ code
91- highlights the potential error of using ` mu ` in the first
92- statement.
93-
9491To trap these kinds of errors, variables are initialized to the
9592special not-a-number (` NaN ` ) value. If ` NaN ` is passed to a
9693log probability function, it will raise a domain exception, which will
0 commit comments