Skip to content

Commit

Permalink
Add ICDF function to pareto distribution
Browse files Browse the repository at this point in the history
Adds ICDF (quantile) function for the Pareto distribution. Source https://en.wikipedia.org/wiki/Pareto_distribution

Issue pymc-devs#6612
  • Loading branch information
james-2001 committed May 6, 2023
1 parent 09215c2 commit 00108d0
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
10 changes: 10 additions & 0 deletions pymc/distributions/continuous.py
Original file line number Diff line number Diff line change
Expand Up @@ -1943,6 +1943,16 @@ def logcdf(value, alpha, m):
msg="alpha > 0, m > 0",
)

def icdf(value, alpha, m):
res = m * pt.pow(1 - value, -1 / alpha)
res = check_icdf_value(res, value)
return check_icdf_parameters(
res,
alpha > 0,
m > 0,
msg="alpha > 0, m > 0",
)


@_default_transform.register(Pareto)
def pareto_default_transform(op, rv):
Expand Down
5 changes: 5 additions & 0 deletions tests/distributions/test_continuous.py
Original file line number Diff line number Diff line change
Expand Up @@ -638,6 +638,11 @@ def test_pareto(self):
{"alpha": Rplusbig, "m": Rplusbig},
lambda value, alpha, m: st.pareto.logcdf(value, alpha, scale=m),
)
check_icdf(
pm.Pareto,
{"alpha": Rplusbig, "m": Rplusbig},
lambda q, alpha, m: st.pareto.ppf(q, alpha, scale=m)
)

@pytest.mark.skipif(
condition=(pytensor.config.floatX == "float32"),
Expand Down

0 comments on commit 00108d0

Please sign in to comment.