Skip to content

Simplify Wald's logcdf method #4436

Closed
@ricardoV94

Description

@ricardoV94

Wald's logcdf checks a lot of conditions for degenerate distribution parameters/values that =0 or =np.inf to decide whether to return a logcdf of -inf or 0. As far as I can tell, this is the only distribution that goes to such lengths to accommodate degenerate cases, some of which are not even allowed by the distribution initialization (or the docstrings or the logp):

https://github.com/pymc-devs/pymc3/blob/823906a3efcf66897eac8a4c89052d9153bca49e/pymc3/distributions/continuous.py#L1138-L1162

Note that the explicit bound parameter checks were added only recently in #4421 and were not in the original implementation of the logcdf method. In fact, they overwrite several of the degenerate lam == 0 checks as well as some implicit (I think) value >= mu & mu == 0 checks.

Also, AFAIK these degenerate conditions are not being tested anywhere.

Unless there is a good reason for it, I would suggest stripping away the degenerate case switches, and simply have something like the following (which I haven't tested yet):

return bound(
    a + tt.log1p(tt.exp(b - a)),
    0 < value, 
    0 < mu,
    0 < lam,
    0 <= alpha,
)

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions