Skip to content
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.
Comment thread
purna135 marked this conversation as resolved.
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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