[FR] add betaincinv
See original GitHub issueSummary
Requesting the betaincinv function be added to jax.scipy.special
. This is the inverse of the regularized incomplete beta function, or the PPF / quantile function for the Beta distribution.
Use case
I’m coming to JAX from numpyro, in which I’m trying to implement Gaussian copula models (example here). I’m looking for models with Beta marginals, which requires the inverse CDF / quantile function for the Beta distribution. After betainc was added in #1998, we have the CDF, but not the quantile function.
Having both the betainc and betaincinv functions would allow the addition of CDF and PPF methods to jax.scipy.stats.beta, much like the norm
class and the scipy implementation. The betaincinv in particular would allow one to transform correlated uniform samples into correlated Beta samples (but the details are unrelated).
Other thoughts
I have no idea how much work this would take. On one hand, PR #1998 didn’t seem like a hugely complex change (though still far above my understanding of JAX, so above all thank you for your hard work). On the other, the SciPy implementation of betainvinc is nasty and I have no idea if this has to be re-implemented in JAX or something like that.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:8
- Comments:12 (6 by maintainers)
Just commenting to say I would also really value this feature and, though you are all most likely already aware, to point out that Stan has gradients implemented for their
inc_beta
function. I believe this is the implementation.Hi! Yep I am planning on adding to both TF and XLA the betaincinv function. I should be getting to this hopefully soon (I have a proto-type written in TF C++, so I should be sending that out shortly. Translating to XLA will take a bit of time, but I’ll have an implementation to compare against 😃 ).
In case you want to get something running sooner, I might recommend using Kumaraswamy marginals: https://en.wikipedia.org/wiki/Kumaraswamy_distribution. Kumaraswamy CDFs / Inverse CDFs are very easy to compute, and it has very similar shapes to a Beta distribution.