-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Add icdf functions for Lognormal, Half Cauchy and Half Normal distributions #6766
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
Changes from 6 commits
711ee4b
59938f7
c9e48ec
1035cc6
8129cbd
63680c2
63fd6ba
08f6974
cdc104c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -856,6 +856,15 @@ def logcdf(value, loc, sigma): | |
msg="sigma > 0", | ||
) | ||
|
||
def icdf(value, loc, sigma): | ||
res = Normal.icdf((value + 1.0) / 2.0, loc, sigma) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a bit annoying because we don't allow users to create a My question is, will this expression work for non-zero This is also a question for the I wonder if the best solution is to reimplement these RandomVariables directly in PyMC in a way that they don't accept a If we go down that path, we can remove the current There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The implemented formula work well even when Allow me some more time to bring some screenshots calling the implemented functions with If you think the best solution is still to reimplement RandomVariables directly in PyMC in a way that they don't accept a loc argument, let me know. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We don't need to do it in this PR, but the fact that it isn't being tested in our suite (and not just the new icdf) is already a good argument to drop it There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good news that it works though! |
||
res = check_icdf_value(res, value) | ||
return check_icdf_parameters( | ||
res, | ||
sigma > 0, | ||
msg="sigma > 0", | ||
) | ||
amyoshino marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
|
||
class WaldRV(RandomVariable): | ||
name = "wald" | ||
|
@@ -1714,12 +1723,22 @@ def logcdf(value, mu, sigma): | |
-np.inf, | ||
normal_lcdf(mu, sigma, pt.log(value)), | ||
) | ||
|
||
return check_parameters( | ||
res, | ||
sigma > 0, | ||
msg="sigma > 0", | ||
) | ||
|
||
def icdf(value, mu, sigma): | ||
res = pt.exp(Normal.icdf(value, mu, sigma)) | ||
res = check_icdf_value(res, value) | ||
amyoshino marked this conversation as resolved.
Show resolved
Hide resolved
|
||
return check_icdf_parameters( | ||
res, | ||
sigma > 0, | ||
msg="sigma > 0", | ||
) | ||
amyoshino marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
|
||
Lognormal = LogNormal | ||
|
||
|
@@ -2121,6 +2140,15 @@ def logcdf(value, loc, beta): | |
msg="beta > 0", | ||
) | ||
|
||
def icdf(value, loc, beta): | ||
res = loc + beta * pt.tan(np.pi * (value) / 2.0) | ||
res = check_icdf_value(res, value) | ||
return check_parameters( | ||
res, | ||
beta > 0, | ||
msg="beta > 0", | ||
) | ||
|
||
|
||
class Gamma(PositiveContinuous): | ||
r""" | ||
|
Uh oh!
There was an error while loading. Please reload this page.