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

Cap the values that Beta.random can generate. #3924

Merged
merged 6 commits into from
May 15, 2020

Conversation

lucianopaz
Copy link
Contributor

@lucianopaz lucianopaz commented May 15, 2020

Closes #3898.

To prevent beta random variates to be equal to 0 or 1, we cap the values to np.nextafter(0,1, dtype) and np.nextafter(1,0, dtype), which give the next floating point nearby zero and one respectively, depending on the precision of the floating point representation.

Depending on what your PR does, here are a few things you might want to address in the description:

  • what are the (breaking) changes that this PR makes?
    Samples returned by Beta.random can never be equal to 0 or 1.

  • important background, or details about the implementation

  • are the changes—especially new features—covered by tests and docstrings?
    Yes

  • consider adding/updating relevant example notebooks

  • right before it's ready to merge, mention the PR in the RELEASE-NOTES.md

Copy link
Contributor

@AlexAndorra AlexAndorra left a comment

Choose a reason for hiding this comment

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

Thanks Luciano, LGTM! I just added some comments to correct typos -- will merge after this is fixed 💯

pymc3/distributions/dist_math.py Outdated Show resolved Hide resolved
pymc3/distributions/dist_math.py Outdated Show resolved Hide resolved
pymc3/distributions/dist_math.py Outdated Show resolved Hide resolved
@AlexAndorra AlexAndorra added this to the 3.9.0 milestone May 15, 2020
@lucianopaz
Copy link
Contributor Author

Thanks for the comments @AlexAndorra, I also fixed the failing test (at least locally). Should be ready to merge now.

@codecov
Copy link

codecov bot commented May 15, 2020

Codecov Report

Merging #3924 into master will increase coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #3924   +/-   ##
=======================================
  Coverage   86.39%   86.40%           
=======================================
  Files          86       86           
  Lines       13722    13728    +6     
=======================================
+ Hits        11855    11861    +6     
  Misses       1867     1867           
Impacted Files Coverage Δ
pymc3/distributions/continuous.py 80.01% <100.00%> (ø)
pymc3/distributions/dist_math.py 91.69% <100.00%> (+0.19%) ⬆️

Copy link
Contributor

@AlexAndorra AlexAndorra left a comment

Choose a reason for hiding this comment

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

Thanks Luciano, looks all good, merging now :)

@AlexAndorra AlexAndorra merged commit 7f307b9 into pymc-devs:master May 15, 2020
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.

Difference in beta support between pymc3 and scipy results in error in sample_prior_predictive()
2 participants