[BUG] Fix Pareto _pdf and _log_pdf returning nonzero values outside support#968
Open
ANANYA542 wants to merge 1 commit intosktime:mainfrom
Open
[BUG] Fix Pareto _pdf and _log_pdf returning nonzero values outside support#968ANANYA542 wants to merge 1 commit intosktime:mainfrom
ANANYA542 wants to merge 1 commit intosktime:mainfrom
Conversation
…upport The Pareto distribution is defined only for x >= scale. However, _pdf and _log_pdf evaluated the formula for all x, returning large wrong positive values for x < scale (e.g., pdf(1.0) = 24.0 when scale=2.0, should be 0.0). Added np.where support boundary checks to both methods, matching the pattern already used by _cdf in the same file.
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.
Description
The Pareto distribution is defined only for
x >= scale. However, _pdf and _log_pdf evaluated the formula blindly for allx, returning large wrong positive values forx < scale(e.g., pdf(1.0) = 24.0 whenscale=2.0, should be0.0).This PR adds
np.wheresupport boundary checks to both methods, matching the pattern already used by _cdf in the same file.Reference Issues/PRs
Fixes #967
What does this implement/fix? Explain your changes.
Added
np.where(x >= scale, ...)guards to _pdf and _log_pdf in pareto.py:0.0forx < scale(was returning large positive values like 384.0)-np.infforx < scale(was returning finite positive values like 5.95)The _cdf method in the same file (line 145) already handled this correctly:
The fix simply applies the same pattern to _pdf and _log_pdf.
Verification:
Screenshot for the same is attatched below:

Does your contribution introduce a new dependency? If yes, which one?
no
What should a reviewer concentrate their feedback on?
np.whereguard is placed correctly in both _pdf and _log_pdf.Did you add any tests for the change?
No new tests needed. The existing test suite validates PDF/CDF/PPF correctness for the Pareto distribution.
For all contributions
How to: add yourself to the all-contributors file in the
skproroot directory (not theCONTRIBUTORS.md). Common badges:code- fixing a bug, or adding code logic.doc- writing or improving documentation or docstrings.bug- reporting or diagnosing a bug (get this pluscodeif you also fixed the bug in the PR).maintenance- CI, test framework, release.See here for full badge reference
For new estimators
docs/source/api_reference/taskname.rst, follow the pattern.Examplessection.python_dependenciestag and ensureddependency isolation, see the estimator dependencies guide.