Closed cgeoga closed 3 years ago
Okay, sort of embarrassing, but I just did some back-of-the-envelope math incorrectly and thought that I could reduce things more than I could. You can write the derivatives in terms of hypergeometric functions, and those are implemented in Julia in a package, but that's obviously not a dependency to pull in here. I'll close this issue, and sorry for the noise.
The
SpecialFunctions
package offers the incomplete beta function asbeta_inc
. For reasons I don't really understand, this function returns a tuple of $I_x(a,b)$ and $1-I_x(a,b)$, so there are perhaps some design questions, but the derivative is computable in closed form, and there are already rules forSpecialFunctions.beta
, so I don't think it would be too difficult. At the moment with DiffRules 1.0.2,ForwardDiff.derivative(a->SpecialFunctions.beta_inc(a, 1.0, 0.3), 1.0)
causes a stack overflow, so it seems like defining a rule for this would have some value.I'm happy to contribute a rule here, but I thought I'd just touch base about the best way to handle the tuple return type. Perhaps it would be best to just locally define a
beta_inc1(a,b,x) = beta_inc(a,b,x)[1]
and implement the derivative manually withDiffRules.@define_diffrule
rather than trying to deal with the tuple return type. Interested to hear thoughts.(edited because I mis-wrote something earlier about the derivatives being computed with the beta distribution pdf)