Skip to content

Update pymc.TruncatedNormal docstring #5546

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

Merged
merged 7 commits into from
Mar 12, 2022
Merged
Changes from 1 commit
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
16 changes: 8 additions & 8 deletions pymc/distributions/continuous.py
Original file line number Diff line number Diff line change
Expand Up @@ -673,14 +673,14 @@ class TruncatedNormal(BoundedContinuous):

Parameters
----------
mu: float
mu : tensor_like of float, optional
Mean.
sigma: float
sigma : tensor_like of float, optional
Standard deviation (sigma > 0).
lower: float (optional)
Left bound.
upper: float (optional)
Right bound.
lower : tensor_like of float, optional
Left bound. Defaults to 0.
Copy link
Member

Choose a reason for hiding this comment

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

I think the defaults are wrong (same for upper). I'd bet the default is no bound or infinity or somehting of the sort

Copy link
Member Author

Choose a reason for hiding this comment

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

I am unable to find out the default value for mu and sigma.
could you please guide me, how to identify these dafult value so that it can help me for other methords.

Copy link
Member

Choose a reason for hiding this comment

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

First check the description in the docstring, sometimes the defaults are incorrectly explained in the extended summary section. If they are not you should read the .dist method and follow the variables defined there and/or function calls to see what the defaults are. Here are some examples, I hope they are illustrative and you can follow the pattern for the rest.

mu

mu = at.as_tensor_variable(floatX(mu))

it is defined straight away here, so it seems like it is not optional actually. @ricardoV94 is this intended? If the value in the function call were 0 instead of None then you would use the default 0 instead of optional for example, however, if some function is called to get the default, it probably means you should use optional and explain the default (or combinations of defaults depending on other parameters) in the description

lower

lower = at.as_tensor_variable(floatX(lower)) if lower is not None else at.constant(-np.inf)

the default in the function call is None, and when it is None, what is actually used is - infinity. When a value is given, that value is used. So lower should be lower : tensor_like of float, default -numpy.inf (and check in the readthedocs preview that it gets rendered correctly).

Copy link
Member

Choose a reason for hiding this comment

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

Looks like the default of mu should indeed be zero, not None

Copy link
Member

Choose a reason for hiding this comment

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

transform as a positional argument is outdated an should be removed from the dist signature

upper : tensor_like of float, optional
Right bound. Defaults to 1.

Examples
--------
Expand Down Expand Up @@ -762,9 +762,9 @@ def logp(

Parameters
----------
value: numeric
value : tensor_like of float
Value(s) for which log-probability is calculated. If the log probabilities for multiple
values are desired the values must be provided in a numpy array or Aesara tensor
values are desired the values must be provided in a numpy array or Aesara tensor.

Returns
-------
Expand Down