The Stan Functions Reference, on this page,

seems to have a typo in the combinations operator such that “alpha - 1” appears on the bottom rather than “n”. This appears in the equation in section 17.1.1 to the PMF.

The Stan Functions Reference, on this page,

seems to have a typo in the combinations operator such that “alpha - 1” appears on the bottom rather than “n”. This appears in the equation in section 17.1.1 to the PMF.

Note that (a + b) choose (a) is equal to (a + b) choose (b). Thus, these are equivalent.

Here’s a Stan program to verify that the normalization is correct (and note that the Stan function is written following the notation in the functions reference: https://github.com/stan-dev/math/blob/develop/stan/math/prim/prob/neg_binomial_lpmf.hpp)

```
data {
int<lower=1> upper_bound;
real<lower = 0> alpha;
real<lower = 0> beta;
}
model {
array[upper_bound + 1] real pmass;
for(i in 0:upper_bound){
pmass[i+1] = neg_binomial_lpmf(i | alpha, beta);
}
print(log_sum_exp(pmass));
}
```

3 Likes