ENH: Add inverse digamma function#130
Conversation
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
|
This PR is ready from my side. |
| const int max_iterations = 20; // avoid infinite loops in pathological cases | ||
| for (int i = 0; i < max_iterations; ++i) { | ||
| double psi_x = cephes::psi(x); | ||
| double psi1_x = cephes::zeta(2, x); // trigamma: psi'(x) = zeta(2, x) |
There was a problem hiding this comment.
| double psi1_x = cephes::zeta(2, x); // trigamma: psi'(x) = zeta(2, x) | |
| double trigamma_x = cephes::zeta(2, x); // trigamma: psi'(x) = zeta(2, x) |
|
For future reference, this PR implements Reference: T. Minka, "Estimating a Dirichlet distribution", 2000. Appendix C |
Co-authored-by: Albert Steppi <[email protected]>
|
Reviews were addressed, let me know if anything else is missing. I did not test GPU support though. |
steppi
left a comment
There was a problem hiding this comment.
Thanks @dschmitz89. Don't worry about GPU tests. The main point of those is to spot CuPy regressions so they don't show up for the first time when making a PR to update xsf in CuPy. We just need to make sure we add them before we eventually submit a CuPy PR for inverse digamma.
I'll merge this one now. For the immediate future, also feel free to merge on your own if you get a green checkmark and the go-ahead from @fbourgey.

Closes #129
Full disclosure: Most of the actual code was generated by a LLM. I pointed it to the reference and fine tuned the convergence criterion and the edge cases.
We will likely need to add a lot more tests, I will look into that in the coming weeks.