-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Censor & Truncate Docstrings #7590
base: main
Are you sure you want to change the base?
Conversation
] |
pymc/distributions/truncated.py
Outdated
with pm.Model(): | ||
normal_dist = pm.Normal.dist(mu=0.0, sigma=1.0) | ||
partially_truncated_normal = pm.Truncated("partially_truncated_normal", normal_dist, lower=-np.inf, upper=1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's put it a s a separate example for more readability with a header explaning it. And include multiple variates like lower=[-np.inf, -np.inf, 0, 0], upper=[np.inf, 1, np.inf, 1], shape=(4,))
explaining that the first one is not truncated / censored, the second one only from above, the third one only from below, and the last one from both sides.
.. code-block:: python | ||
|
||
with pm.Model(): | ||
normal_dist = pm.Normal.dist(mu=0.0, sigma=1.0) | ||
truncated_normal = pm.Truncated("truncated_normal", normal_dist, lower=-1, upper=1) | ||
|
||
Partial truncatin of normal distributions achieved by passing +/-inf truncation points. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Partial truncatin of normal distributions achieved by passing +/-inf truncation points. | |
Partial truncation of normal distributions achieved by passing +/-inf truncation points. |
Partial censoring of normal distributions achienved by passing +/-inf censor points. | ||
Examples of 4 censor conditions: uncensored (-inf, inf), upper censored (-inf, 1), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
First emphasize that censoring bounds can change across dimensions of the variable, and then enumerate the examples. If they don't change, one can use None
as upper or lower, not only +/-np.inf
.. code-block:: python | ||
with pm.Model(): | ||
normal_dist = pm.Normal.dist(mu=0.0, sigma=1.0) | ||
partially_censored_normals = pm.Censored("partially_censored_normals", normal_dist, lower=[-np.inf, -np.inf, -1, -1], upper=[np.inf, 1, np.inf, 1], shape=(4,)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
make it multiple line so it renders nicely in the docs: https://pymcio--7590.org.readthedocs.build/projects/docs/en/7590/api/distributions/censored.html
The name is probably too long
Partial censoring of normal distributions achienved by passing +/-inf censor points. | ||
Examples of 4 censor conditions: uncensored (-inf, inf), upper censored (-inf, 1), | ||
lower censored (-1, inf), and both censored (-1, 1) | ||
.. code-block:: python |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you need to leave a blank line between the description and the code example for it to render correctly: https://pymcio--7590.org.readthedocs.build/projects/docs/en/7590/api/distributions/censored.html
Before: https://www.pymc.io/projects/docs/en/stable/api/distributions/censored.html
Description
Provides updated type listing for lower and upper censor & truncate points to include
int
andarray-like
.Additionally, provides an example using -/+inf for partial censor or truncation.
Related Issue
Checklist
Type of change
📚 Documentation preview 📚: https://pymc--7590.org.readthedocs.build/en/7590/