I find it strange that we loop over the size of alpha but inside the loop we read n_vec: if alpha_vec is a scalar and n_vec is a vector, wouldn’t we be computing the wrong quantity (and ignoring a number of values from n_vec)?
Also the other *cdf functions for neg_binomial use the same pattern.
I’ve been using expose_stan_functions in R to play about with this, and results look correct… but I don’t know why! Can anybody think of an example that shows it’s doing the wrong thing, or explain why it’s actually fine? @syclik, @Bob_Carpenter, @nhuurre, @martinmodrak
Thanks @martinmodrak, I had forgotten about that (I thought our problems in these functions were limited to the numerics). Also neg_binomial_2_cdf has the same bug, while neg_binomial_2_lccdf is also affected since it delegates to neg_binomial_lccdf. On the other hand, neg_binomial_2_lcdf seems to be fine.