-
-
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?
Changes from all commits
03764d0
685dcd0
eb31d65
578808b
f070e88
50948b4
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 |
---|---|---|
|
@@ -84,9 +84,9 @@ class Censored(Distribution): | |
|
||
.. warning:: dist will be cloned, rendering it independent of the one passed as input. | ||
|
||
lower : float or None | ||
lower : float, int, array-like or None | ||
Lower (left) censoring point. If `None` the distribution will not be left censored | ||
upper : float or None | ||
upper : float, int, array-like or None | ||
Upper (right) censoring point. If `None`, the distribution will not be right censored. | ||
|
||
Warnings | ||
|
@@ -101,11 +101,20 @@ class Censored(Distribution): | |
|
||
Examples | ||
-------- | ||
Censoring with upper & lower points set to +/-1 | ||
.. code-block:: python | ||
|
||
with pm.Model(): | ||
normal_dist = pm.Normal.dist(mu=0.0, sigma=1.0) | ||
censored_normal = pm.Censored("censored_normal", normal_dist, lower=-1, upper=1) | ||
|
||
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 commentThe 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 |
||
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 commentThe 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 |
||
""" | ||
|
||
rv_type = CensoredRV | ||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -266,9 +266,9 @@ class Truncated(Distribution): | |||||
|
||||||
.. warning:: dist will be cloned, rendering it independent of the one passed as input. | ||||||
|
||||||
lower: tensor_like of float or None | ||||||
lower: tensor_like of float, int, or None | ||||||
Lower (left) truncation point. If `None` the distribution will not be left truncated. | ||||||
upper: tensor_like of float or None | ||||||
upper: tensor_like of float, int, or None | ||||||
Upper (right) truncation point. If `None`, the distribution will not be right truncated. | ||||||
max_n_steps: int, defaults 10_000 | ||||||
Maximum number of resamples that are attempted when performing rejection sampling. | ||||||
|
@@ -285,12 +285,20 @@ class Truncated(Distribution): | |||||
|
||||||
Examples | ||||||
-------- | ||||||
Truncation with upper & lower points set to +/-1 | ||||||
.. 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 commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
Examples of 4 truncation conditions: untruncated (-inf, inf), upper truncated (-inf, 1), | ||||||
lower truncated (-1, inf), and both truncated (-1, 1) | ||||||
.. code-block:: python | ||||||
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, -np.inf, -1, -1], upper=[np.inf, 1, np.inf, 1], shape=(4,)) | ||||||
""" | ||||||
|
||||||
rv_type = TruncatedRV | ||||||
|
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