Skip to content

Commit 8a60c21

Browse files
committed
A few more cleanups
1 parent 63bd23c commit 8a60c21

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

knitr/reduce-sum/reduce_sum_tutorial.Rmd

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
title: "Reduce Sum: A Minimal Example"
3-
date: "16 June 2020"
3+
date: "12 Nov 2020"
44
output: html_document
55
---
66

@@ -159,7 +159,7 @@ for(n in 1:N) {
159159

160160
Now it is clear that the calculation is the sum (up to a
161161
proportionality constant) of a number of conditionally independent
162-
Bernoulli log probability statements. So whenever we need to calculate
162+
Bernoulli log probability statements. Whenever we need to calculate
163163
a large sum where each term is independent of all others and associativity
164164
holds, then `reduce_sum` is useful.
165165

@@ -171,9 +171,9 @@ This is because we only need this likelihood term up to a proportionality
171171
constant for MCMC to work and for some distributions this can make code
172172
run noticeably faster. Because of the way that `_lupmf` features work,
173173
Stan only allows them in the model block or in user-defined probability
174-
distribution functions, and so the function we write for `reduce_sum`
175-
will need to be a probability distribution function (suffixed with
176-
`_lpdf` or `_lpmf`) for us to use `binomial_logit_lupmf` on the inside.
174+
distribution functions, and for us to use `binomial_logit_lupmf` the
175+
function we write for `reduce_sum` will need to be a probability distribution
176+
function (suffixed with `_lpdf` or `_lpmf`).
177177
If the difference in the normalized and unnormalized functions is not
178178
relevant for your application, you can call your `reduce_sum` function
179179
whatever you like.
@@ -216,11 +216,11 @@ target += partial_sum_lupmf(n_redcards[1:M], 1, M, n_games, rating, beta) // Sum
216216
target += partial_sum_lupmf(n_redcards[(M + 1):N], M + 1, N, n_games, rating, beta); // Sum terms M + 1 to N
217217
```
218218

219-
By passing `partial_sum_lupmf` to `reduce_sum`, we allow Stan to
219+
By passing `partial_sum_lupmf` to `reduce_sum`, we tell Stan to
220220
automatically break up these calculations and do them in parallel.
221221

222222
Notice the difference in how `n_redcards` is split in half (to reflect
223-
which terms of the sum are being accumulated) and the rest of the arguments
223+
which terms of the sum are being accumulated) and the rest of the arguments
224224
(`n_games`, `x`, and `beta`) are left alone. This distinction is important
225225
and more fully described in the User's Guide section on
226226
[Reduce-sum](https://mc-stan.org/docs/2_23/stan-users-guide/reduce-sum.html).

0 commit comments

Comments
 (0)