question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add incomplete gamma functions

See original GitHub issue

i.e., scipy.special.gammainc and scipy.special.gammaincc.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:3
  • Comments:8 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
mattjjcommented, Aug 17, 2019

Awesome, thanks for your interest!

AIUI there are basically two ways to add functions like these:

  1. implement them ourselves in terms of lax primitives, like how we implement, say, expit or logaddexp
  2. find an implementation in the C++ XLA client math library and add it to JAX as a primitive in lax.py, like we do with lax.digamma here.

Interestingly, these two approaches are pretty similar: the XLA client libraries just implement functions in terms of XLA:HLO, and that’s exactly what we get when we write functions at the Python level in terms of the primitives in lax.py. That’s because the lax.py primitives are essentially 1:1 with XLA HLO (or in a few cases client library functions), so they translate to the same XLA computations. In general I think it’s easier and nicer to implement things in Python in terms of lax.py, but on the other hand for trickier numerical computations it can be good to reuse the effort in the XLA client library, and then we also get to share any updates or fixes across XLA frontends.

My guess is that (1) is the best approach to start with. On that front, I just noticed that @fehiepsi added some calculations involving incomplete gamma expressions in random.py, so that might be a good source of clues.

For approach (2) this seems like the relevant part of the XLA client math library but a quick glance didn’t turn up incomplete gamma stuff. Do you see any?

So overall my recommendation is to try implementing an incomplete gamma function in terms of lax.py primitives!

0reactions
hawkinspcommented, Jan 29, 2020

This was fixed by @srvasude in PR #2064 .

Read more comments on GitHub >

github_iconTop Results From Across the Web

Incomplete gamma function - Wikipedia
In mathematics, the upper and lower incomplete gamma functions are types of special functions which arise as solutions to various mathematical problems such ......
Read more >
Integral of incomplete gamma function - Math Stack Exchange
First: I fear that your initial integral is ill defined at 0 since the integrant will be equivalent to z−|M|−1Γ(A) there (for A>0 ......
Read more >
Incomplete Gamma Function -- from Wolfram MathWorld
The "complete" gamma function Gamma(a) can be generalized to the incomplete gamma function Gamma(a,x) such that Gamma(a)=Gamma(a,0). This "upper" incomplete ...
Read more >
Incomplete Gamma Function - an overview - ScienceDirect.com
Incomplete gamma functions are defined and their relations to the error function and the exponential integral are ... Adding these two relations, we...
Read more >
expint: Exponential integral and incomplete gamma function
3 Incomplete gamma function​​ dt, x > 0, a > 0. Function pgamma already implements this function in R (just note the differing...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found