I’m looking at the algorithm for calculating `grad_F32`

and working on getting the tests I wrote to pass. One of the things that comes up is that even when 3F2 power series representation is defined, the gradient power series is not as the gradient power series relies on the digamma function, which is not finite at negative integers. Current behavior is to return wrong results. My preferred solution is to make it throw for negative integer arguments in addition to throwing when 3F2 will not converge (it must meet those conditions as well).

The only reason this wouldn’t be a great bugfix is if we know that there are some models that relay on traversing that space (over a negative integer in 3F2(a1,a2,a3,b1,b2,z). Anyone know for sure either way?

I think this is the last thing I have to tackle before I can wrap up that bugfix PR.

If there’s no way to make it return acceptable results, then it should throw an exception with an informative error message.

If it’s returning the wrong results now, you’ll be doing people a favor by having it throw instead.

Thanks for working through all of this.

It’s not so much that there’s no way but that I don’t have that on hand so it’ll be a separate PR for a feature. I want to keep the current PR down to 1) giving accurate answers when we don’t throw and 2) throwing when we can’t give accurate answers.

For the lower arguments any negative integer values indicate poles for which the power series is ill-defined, https://en.wikipedia.org/wiki/Generalized_hypergeometric_function#Convergence_conditions. Mathematica may be relying on a special analytic continuation of 3F2 to give values for certain negative integer inputs but they may also not, in general, be applicable in all cases. See the infamous 1+ 2 + 3 + … = -1/12 result.

The function should throw if the lower arguments are negative integers. The application to the beta-binomial density never inputs negative arguments anyways.

Great, we’re on the same page. The convergence check functions take care of this. I’ll try to doc that we’re only covering part of the range it’s possible to call these functions on.