Skip to content

Commit 0c626ab

Browse files
author
Lucas Eckes
committed
Add icdf functions for Inverse Gamma distribution
1 parent 340e403 commit 0c626ab

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

pymc/distributions/continuous.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2530,6 +2530,16 @@ def logcdf(value, alpha, beta):
25302530
beta > 0,
25312531
msg="alpha > 0, beta > 0",
25322532
)
2533+
2534+
def icdf(value, alpha, beta):
2535+
res = 1 / Gamma.icdf(value=1-value, alpha=alpha, scale=1 / beta)
2536+
res = check_icdf_value(res, value)
2537+
return check_icdf_parameters(
2538+
res,
2539+
alpha > 0,
2540+
beta > 0,
2541+
msg="alpha > 0, beta > 0",
2542+
)
25332543

25342544

25352545
class ChiSquared:

tests/distributions/test_continuous.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -705,6 +705,13 @@ def test_fun(value, mu, sigma):
705705
decimal=select_by_precision(float64=4, float32=3),
706706
)
707707

708+
def test_inverse_gamma_icdf(self):
709+
check_icdf(
710+
pm.InverseGamma,
711+
{"alpha": Rplusbig, "beta": Rplusbig},
712+
lambda q, alpha, beta: st.invgamma.ppf(q, alpha, scale=beta),
713+
)
714+
708715
def test_pareto(self):
709716
check_logp(
710717
pm.Pareto,

0 commit comments

Comments
 (0)