Skip to content

Logcdf methods of several distributions do not check for invalid parameters #4399

Closed
@ricardoV94

Description

@ricardoV94

In working in #4393 and #4387 I realized that several logcdf methods for continuous distributions do not adequately check for invalid parameters and can return either nan or wrong results. If there is an interest, I am willing to do a new PR to fix those as well as to extend the check_logcdf to automatically test that -inf is returned for invalid parameters (i.e., outside the supported range).

Here are some currently failing examples:

pm.Normal.dist(sigma=-1).logcdf(1).eval()  # returns -1.841
pm.Pareto.dist(alpha=1, m=-1).logcdf(1).eval()  # returns 0.693
pm.Weibull.dist(alpha=-1, beta=1).logcdf(1).eval()  # returns -0.459
pm.Cauchy.dist(alpha=0, beta=-1).logcdf(1).eval()  # returns -1.386

pm.Exponential.dist(lam=-1).logcdf(1).eval()  # returns nan
pm.HalfCauchy.dist(beta=-1).logcdf(1).eval()  # returns nan

This and the changes included in #4393 could also be used in check_logp to test that the logp is also correctly handling invalid values / parameters. I would be surprised to find issues in current implementations, given that every logp return seems to be wrapped in bound, but it could still be helpful for people developing new distributions or refactoring old ones...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions