-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Fix bug in which TruncatedNormal returns -inf for all values if any value is out of bounds #6128
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
Changes from 2 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
2316b90
use switch instead of relying on check_parameters
adrn a8c104f
add small regression test of evaluating logp for truncatednormal
adrn 4545894
Update pymc/distributions/continuous.py
adrn 0c5f742
Update pymc/tests/distributions/test_continuous.py
adrn d6621de
move test by @ricardov94's suggestion
adrn d0a5626
only use switch logic if needed, as in general truncated distributions
adrn f9b90ba
use isinf, isneginf
adrn 8c9dbd2
apply pre-commit
adrn File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Actually to be equivalent to what we had before we should do something like this:
pymc/pymc/distributions/truncated.py
Lines 316 to 320 in c53cd2f
Uh oh!
There was an error while loading. Please reload this page.
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.
Isn't that equivalent to what is implemented here because of the default values for lower and upper?
pymc/pymc/distributions/continuous.py
Lines 714 to 715 in 91cbebd
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.
We retrieve the None case here:
pymc/pymc/distributions/continuous.py
Lines 763 to 764 in 91cbebd
So in those cases we avoid introducing the useless switch. It's a small optimization but I don't see any reason yo modify it.
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.
Oh I see. OK
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.
The last commit makes the implementation here more analogous to the general truncated case you linked above - thanks for that pointer!
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.
Thanks @ricardoV94 for taking a look and helping out already! Let me know if the implementation in the latest few commits looks ok. Also, it looks like this PR is waiting for approval to run the full test suite.