Skip to content

Conversation

@tingiskhan
Copy link
Contributor

Reference Issues/PRs

Fixes #651

What does this implement/fix? Explain your changes.

Adds a wrapper for the methods s.t. values outside of support are set to 0 and -np.infty.

Does your contribution introduce a new dependency? If yes, which one?

No.

What should a reviewer concentrate their feedback on?

Did you add any tests for the change?

Yes.

Any other comments?

No,

PR checklist

For all contributions
  • I've added myself to the list of contributors with any new badges I've earned :-)
    How to: add yourself to the all-contributors file in the skpro root directory (not the CONTRIBUTORS.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 plus code if you also fixed the bug in the PR).maintenance - CI, test framework, release.
    See here for full badge reference
  • The PR title starts with either [ENH], [MNT], [DOC], or [BUG]. [BUG] - bugfix, [MNT] - CI, test framework, [ENH] - adding or improving code, [DOC] - writing or improving documentation or docstrings.
For new estimators
  • I've added the estimator to the API reference - in docs/source/api_reference/taskname.rst, follow the pattern.
  • I've added one or more illustrative usage examples to the docstring, in a pydocstyle compliant Examples section.
  • If the estimator relies on a soft dependency, I've set the python_dependencies tag and ensured
    dependency isolation, see the estimator dependencies guide.

Copy link
Collaborator

@fkiraly fkiraly left a comment

Choose a reason for hiding this comment

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

Thanks!

Could we avoid decorators to ensure the extension contract has a fixed signature?
That would also mean having a "three casess" distinction in _cdf rather than two cases only.

We should also add a small regression test.

@tingiskhan
Copy link
Contributor Author

Thanks!

Could we avoid decorators to ensure the extension contract has a fixed signature? That would also mean having a "three casess" distinction in _cdf rather than two cases only.

We should also add a small regression test.

Absolutely, no worries. Would you be fine with just removing the decorator and re-using the inner-function? I.e.

    def _set_to_constant_where_negative(x: np.ndarray, const: float) -> np.ndarray:
        return np.where(x < 0, const, result)

    def _log_pmf(self, x):
        log_prob_zero = np.log(1.0 - self.p)
        log_prob_hurdle = np.log(self.p)

        is_zero = x == 0
        result = np.where(is_zero, log_prob_zero, log_prob_positive)

        return _set_to_constant_where_negative(result, const=-np.inf)

@fkiraly
Copy link
Collaborator

fkiraly commented Nov 27, 2025

Would you be fine with just removing the decorator and re-using the inner-function? I.e.

Yes, sure - as long as it is vectorized (which it is)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug module:probability&simulation probability distributions and simulators

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Hurdle CDF is wrong for negative values

2 participants