Skip to content

added icdf for asymmetric laplace distribution #7141

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 9 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion pymc/distributions/continuous.py
Original file line number Diff line number Diff line change
Expand Up @@ -1641,7 +1641,22 @@ def logp(value, b, kappa, mu):
kappa > 0,
msg="b > 0, kappa > 0",
)

def icdf(value, b, kappa, mu):
res = pt.switch(pt.le(b, 0),
lambda: ValueError("Scale Parameter b must be positive"),
pt.switch(
pt.le(value, 0.5),
lambda: mu - (b / kappa) * pt.log(2 * value),
lambda: mu + (b / kappa) * pt.log(2 * (1 - value))
)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why lambda functions here...?

)
res = check_icdf_parameters(res, value)
return check_icdf_parameters(
res,
b > 0,
kappa > 0,
msg="b > 0, kappa > 0"
)

class LogNormal(PositiveContinuous):
r"""
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 @@ -488,6 +488,11 @@ def test_laplace_asymmetric(self):
laplace_asymmetric_logpdf,
decimal=select_by_precision(float64=6, float32=2),
)
check_icdf(
pm.AsymmetricLaplace,
{"b": Rplus, "kappa": Rplus, "mu": R},
lambda q, kappa, mu, b: st.laplace_asymmetric.ppf(q, kappa, mu, b)
)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have you checked if this test pass?


def test_lognormal(self):
check_logp(
Expand Down