WIP: Partial derivatives of betainc
Chain rules for partial derivatives of incomplete beta. Code is by @arzwa and taken from
https://github.com/arzwa/IncBetaDer/blob/main/src/beta_inc_grad.jl
Related to effort to provide julia implementations of pdf/cdf like functions (https://github.com/JuliaStats/StatsFuns.jl/pull/113) and associated problems (https://github.com/JuliaStats/Distributions.jl/issues/1334)
The algorithm used to compute the partial derivatives doesn't seem very accurate (I had to go down to atol=0.1 in the tests). I'll see if any other languages use a different algorithm
After reviewing the algorithms used for incomplete beta it is obvious that different approximations perform better in different domains of input variables. Unfortunately I have only found derivations of partial derivatives for a continued fraction approximation of incomplete beta (however not the one we are using for the incomplete beta).
We can put these derivatives in place while acknowledging that they are not be accurate for all ranges of inputs, or we can hold off until someone derives partial derivatives for more of the approximation methods (if that is even possible).
Thoughts?
For my future self: https://duetosymmetry.com/notes/take-derivative-continued-fraction/