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

Fix rand for truncated normal with 0 variance #1721

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ararslan
Copy link
Member

Fixes #1712.

if a <= μ <= b
z = 0.0
else
return NaN
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 we would want to catch this case earlier in truncated: A distribution with zero mass is by definition not a distribution. See #843.

Copy link
Member

Choose a reason for hiding this comment

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

Maybe let's throw an error here? I don't think returning NaN is particularly useful.

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've opened #1723 as a means of catching this case earlier, but I'd also be fine throwing an error here.

@ararslan
Copy link
Member Author

Seems I was beaten to the punch by about 2 years: #1273 🙂

@codecov-commenter
Copy link

codecov-commenter commented May 11, 2023

Codecov Report

Patch coverage: 100.00% and project coverage change: +0.11 🎉

Comparison is base (fa8c30d) 85.75% compared to head (b488b3c) 85.87%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1721      +/-   ##
==========================================
+ Coverage   85.75%   85.87%   +0.11%     
==========================================
  Files         138      138              
  Lines        8339     8344       +5     
==========================================
+ Hits         7151     7165      +14     
+ Misses       1188     1179       -9     
Impacted Files Coverage Δ
src/truncated/normal.jl 86.13% <100.00%> (+0.52%) ⬆️

... and 4 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Infinite loop in truncated normal distribution
3 participants