Skip to content

Commit 1c0be8f

Browse files
committed
Support InverseGamma icdf
Co-authored-by: lucaseckes
1 parent 6dbf60c commit 1c0be8f

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

pymc/distributions/continuous.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2532,6 +2532,9 @@ def logcdf(value, alpha, beta):
25322532
msg="alpha > 0, beta > 0",
25332533
)
25342534

2535+
def icdf(value, alpha, beta):
2536+
return icdf(1 / Gamma.dist(alpha, beta), value)
2537+
25352538

25362539
class ChiSquared:
25372540
r"""

tests/distributions/test_continuous.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -687,6 +687,13 @@ def test_inverse_gamma_logcdf(self):
687687
lambda value, alpha, beta: st.invgamma.logcdf(value, alpha, scale=beta),
688688
)
689689

690+
def test_inverse_gamma_icdf(self):
691+
check_icdf(
692+
pm.InverseGamma,
693+
{"alpha": Rplusbig, "beta": Rplusbig},
694+
lambda q, alpha, beta: st.invgamma.ppf(q, alpha, scale=beta),
695+
)
696+
690697
@pytest.mark.skipif(
691698
condition=(pytensor.config.floatX == "float32"),
692699
reason="Fails on float32 due to scaling issues",

0 commit comments

Comments
 (0)