Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rule for SpecialFunctions.beta_inc #58

Closed
cgeoga opened this issue Jun 1, 2021 · 1 comment
Closed

Rule for SpecialFunctions.beta_inc #58

cgeoga opened this issue Jun 1, 2021 · 1 comment

Comments

@cgeoga
Copy link

cgeoga commented Jun 1, 2021

The SpecialFunctions package offers the incomplete beta function as beta_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 for SpecialFunctions.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 with DiffRules.@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)

@cgeoga
Copy link
Author

cgeoga commented Jun 1, 2021

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.

@cgeoga cgeoga closed this as completed Jun 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant