[BUG] reject non-positive sigma/scale in Normal and Laplace#960
Open
Ayushigitgithub wants to merge 2 commits intosktime:mainfrom
Open
[BUG] reject non-positive sigma/scale in Normal and Laplace#960Ayushigitgithub wants to merge 2 commits intosktime:mainfrom
Ayushigitgithub wants to merge 2 commits intosktime:mainfrom
Conversation
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Reference Issues/PRs
Closes #959
What does this implement/fix? Explain your changes.
Adds constructor-level validation for non-positive scale parameters in
NormalandLaplace.Changes:
Normalnow raisesValueErrorwhensigma <= 0Laplacenow raisesValueErrorwhenscale <= 0Normal(mu=0, sigma=-1)Normal(mu=0, sigma=0)Laplace(mu=0, scale=-1)Laplace(mu=0, scale=0)Why is this needed?
Normal(mu=0, sigma=-1).pdf(0)previously returned-0.3989422804014327Laplace(mu=0, scale=-1).pdf(0)previously returned-0.5A pdf should never be negative, so these invalid parameters should be rejected early instead of silently producing mathematically invalid outputs.
Does your contribution introduce a new dependency? If yes, which one?
No
What should a reviewer concentrate their feedback on?
Constructor-level validation for non-positive
sigma/scaleinNormalandLaplace, and whether the added regression tests intest_proba_basic.pyare the right place and scope for this fix.Did you add any tests for the change?
Yes.
Added tests for:
Normal(mu=0, sigma=-1)Normal(mu=0, sigma=0)Laplace(mu=0, scale=-1)Laplace(mu=0, scale=0)These verify that non-positive scale parameters are rejected with
ValueError.Any other comments?
Closes #959
PR checklist
For all contributions