Skip to content

Commit 34e1d94

Browse files
authored
Merge pull request #914 from yixuan/bugfix
Various documentation fixes for Stan User's Guide
2 parents 21a3211 + f379532 commit 34e1d94

12 files changed

+37
-38
lines changed

src/stan-users-guide/complex-numbers.qmd

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ numbers, with the corresponding imaginary component set to zero.
6161

6262
```stan
6363
complex z1 = 3; // int promoted to 3 + 0i
64-
complex z2 = 3.2; // real promoted to 3.2 + 0.i
64+
complex z2 = 3.2; // real promoted to 3.2 + 0.0i
6565
```
6666

6767

@@ -149,7 +149,7 @@ vector.
149149
rv = [2 + 3i, 1.9 - 2.3i];
150150
```
151151

152-
Complex matrices and vectors support all of the standard arithetmic
152+
Complex matrices and vectors support all of the standard arithmetic
153153
operations including negation, addition, subtraction, and
154154
multiplication (division involves a solve, and isn't a simple
155155
arithmetic operation for matrices). They also support transposition.

src/stan-users-guide/dae.qmd

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -113,14 +113,13 @@ in Stan (see the [user-defined functions chapter](user-functions.qmd) for
113113
more information on coding user-defined functions).
114114

115115
```stan
116-
vector chem(real t, vector yy, vector yp,
117-
real alpha, real beta, real gamma) {
118-
vector[3] res;
119-
res[1] = yp[1] + alpha * yy[1] - beta * yy[2] * yy[3];
120-
res[2] = yp[2] - alpha * yy[1] + beta * yy[2] * yy[3] + gamma * yy[2] * yy[2];
121-
res[3] = yy[1] + yy[2] + yy[3] - 1.0;
122-
return res;
123-
}
116+
vector chem(real t, vector yy, vector yp,
117+
real alpha, real beta, real gamma) {
118+
vector[3] res;
119+
res[1] = yp[1] + alpha * yy[1] - beta * yy[2] * yy[3];
120+
res[2] = yp[2] - alpha * yy[1] + beta * yy[2] * yy[3] + gamma * yy[2] * yy[2];
121+
res[3] = yy[1] + yy[2] + yy[3] - 1.0;
122+
return res;
124123
}
125124
```
126125

src/stan-users-guide/floating-point.qmd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ There are value functions `positive_infinity()` and
116116
`negative_infinity()` as well as a test function `is_inf()`.
117117

118118
Positive and negative infinity have the expected comparison behavior,
119-
so that `negative_infinty() < 0` evaluates to true (represented with 1
119+
so that `negative_infinity() < 0` evaluates to true (represented with 1
120120
in Stan). Also, negating positive infinity leads to negative infinity
121121
and vice-versa.
122122

src/stan-users-guide/gaussian-processes.qmd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -890,7 +890,7 @@ is the matrix of covariances between inputs $x$ and $\tilde{x}$, which
890890
in the case of the exponentiated quadratic covariance function
891891
would be
892892
$$
893-
K(x \mid \alpha, \rho)_{i, j} = \eta^2 \exp\left(-\dfrac{1}{2 \rho^2}
893+
K(x \mid \alpha, \rho)_{i, j} = \alpha^2 \exp\left(-\dfrac{1}{2 \rho^2}
894894
\sum_{d=1}^D \left(x_{i,d} - \tilde{x}_{j,d}\right)^2\right).
895895
$$
896896

src/stan-users-guide/measurement-error.qmd

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -262,10 +262,10 @@ y_j &= \log \left( \frac{r^t_j / (n^t_j - r^t_j)}
262262
and corresponding standard errors
263263
$$
264264
\sigma_j = \sqrt{
265-
\frac{1}{r^T_i}
266-
+ \frac{1}{n^T_i - r^T_i}
267-
+ \frac{1}{r^C_i}
268-
+ \frac{1}{n^C_i - r^C_i}
265+
\frac{1}{r^T_j}
266+
+ \frac{1}{n^T_j - r^T_j}
267+
+ \frac{1}{r^C_j}
268+
+ \frac{1}{n^C_j - r^C_j}
269269
}.
270270
$$
271271

src/stan-users-guide/multi-indexing.qmd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ example, consider the following.
7777

7878
```stan
7979
array[2, 3] int c;
80-
// ... define: c = ((1, 3, 5), ((7, 11, 13))
80+
// ... define: c = ((1, 3, 5), (7, 11, 13))
8181
array[4] int idxs;
8282
// ... define: idxs = (2, 2, 1, 2)
8383
array[4, 3] int d

src/stan-users-guide/parallelization.qmd

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ be used with multi-processing.
1616
The advantages of reduce with summation are:
1717

1818
1. More flexible argument interface, avoiding the packing and
19-
unpacking that is necessary with rectanguar map.
19+
unpacking that is necessary with rectangular map.
2020
2. Partitions data for parallelization automatically (this is done manually
21-
in rectanguar map).
21+
in rectangular map).
2222
3. Is easier to use.
2323

2424
The advantages of rectangular map are:
@@ -92,7 +92,7 @@ See details [below](#reduce-sum-grainsize).
9292

9393
For efficiency and convenience additional
9494
shared arguments can be passed to every term in the sum. So for the
95-
array ```{ x1, x2, ... }``` and the shared arguments ```s1, s2, ...```stan
95+
array ```{ x1, x2, ... }``` and the shared arguments ```s1, s2, ...```
9696
the effective sum (with individual terms) looks like:
9797

9898
```stan
@@ -137,7 +137,7 @@ without modification from the ```reduce_sum``` / `reduce_sum_static` call)
137137
The user-provided function ```f``` is expected to compute the partial
138138
sum with the terms ```start``` through ```end``` of the overall
139139
sum. The user function is passed the subset ```x[start:end]``` as
140-
```x_slice```. ```start``` and ```end``` are passed so that ```f```stan
140+
```x_slice```. ```start``` and ```end``` are passed so that ```f```
141141
can index any of the tailing ```sM``` arguments as necessary. The
142142
trailing ```sM``` arguments are passed without modification to every
143143
call of ```f```.
@@ -452,8 +452,8 @@ data {
452452
}
453453
transformed data {
454454
// K = 3 shards
455-
array[3, 4] = { y[1:4], y[5:8], y[9:12] int ys };
456-
array[3, 4] = { x[1:4], x[5:8], x[9:12] real xs };
455+
array[3, 4] int ys = { y[1:4], y[5:8], y[9:12] };
456+
array[3, 4] real xs = { x[1:4], x[5:8], x[9:12] };
457457
array[3] vector[0] theta;
458458
}
459459
parameters {

src/stan-users-guide/problematic-posteriors.qmd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,7 @@ p(\phi \mid y)
467467
\end{align*}
468468

469469
If $N = 9$ and each $y_n = 1$, the posterior is
470-
$\textsf{beta}(\phi \mid 9.5,0,5)$. This posterior is unbounded as $\phi
470+
$\textsf{beta}(\phi \mid 9.5,0.5)$. This posterior is unbounded as $\phi
471471
\rightarrow 1$. Nevertheless, the posterior is proper, and although
472472
there is no posterior mode, the posterior mean is well-defined with a
473473
value of exactly 0.95.

src/stan-users-guide/proportionality-constants.qmd

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ parameters {
8484
real x;
8585
}
8686
model {
87-
target += normal_lupdf(x | mu, sigma)
87+
target += normal_lupdf(x | mu, sigma);
8888
}
8989
```
9090

@@ -135,10 +135,10 @@ The following code demonstrates the different behaviors:
135135
```stan
136136
functions {
137137
real custom1_lpdf(x) {
138-
return normal_lupdf(x | 0.0, 1.0)
138+
return normal_lupdf(x | 0.0, 1.0);
139139
}
140140
real custom2_lpdf(x) {
141-
return normal_lpdf(x | 0.0, 1.0)
141+
return normal_lpdf(x | 0.0, 1.0);
142142
}
143143
}
144144
parameters {

src/stan-users-guide/reparameterization.qmd

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,13 +102,13 @@ model {
102102
The new parameters, `phi` and `lambda`, are declared in the
103103
parameters block and the parameters for the Beta distribution,
104104
`alpha` and `beta`, are declared and defined in the
105-
transformed parameters block. And If their values are not of interest,
105+
transformed parameters block. And if their values are not of interest,
106106
they could instead be defined as local variables in the model as
107107
follows.
108108

109109
```stan
110110
model {
111-
real alpha = lambda * phi
111+
real alpha = lambda * phi;
112112
real beta = lambda * (1 - phi);
113113
// ...
114114
for (n in 1:N) {

0 commit comments

Comments
 (0)