Skip to content
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

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 4 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
7 changes: 5 additions & 2 deletions pymc/distributions/censored.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -106,6 +106,9 @@ class Censored(Distribution):
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)
with pm.Model():
normal_dist = pm.Normal.dist(mu=0.0, sigma=1.0)
partially_censored_normal = pm.Censored("partially_censored_normal", normal_dist, lower=-1, upper=np.inf)
"""

rv_type = CensoredRV
Expand Down
8 changes: 5 additions & 3 deletions pymc/distributions/truncated.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -290,7 +290,9 @@ class Truncated(Distribution):
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)

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)
Copy link
Member

@ricardoV94 ricardoV94 Nov 26, 2024

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.

"""

rv_type = TruncatedRV
Expand Down