Skip to content

InverseGamma logcdf method fails with invalid parameters when array is used #4340

Closed
@ricardoV94

Description

@ricardoV94

The theano.tensor function gammaincc fails with a C code assertion that exits the process, when called with negative arguments. This function is now being called in the logcdf method of the InverseGamma distribution (and after #4331, in the logcdf of the Poisson distribution).

Using bound avoids the exception when a single value is evaluated. However, it fails when an array/tensor with one or multiple values is used, since bound is not lazy.

Should we be concerned about this? From the docstrings, it seems that all logcdf methods are intended to work with both scalars and arrays/tensors values.

pm.InverseGamma.dist(alpha=-1, beta=5).logcdf(1).eval()  # returns -np.inf
pm.InverseGamma.dist(alpha=1, beta=5).logcdf(-1).eval()  # returns -np.inf

pm.InverseGamma.dist(alpha=-1, beta=5).logcdf(np.array([1])).eval()  # fails assertion and exits process
pm.InverseGamma.dist(alpha=1, beta=5).logcdf(np.array([-1])).eval()  # fails assertion and exits process
pm.InverseGamma.dist(alpha=-1, beta=5).logcdf(np.array([1, 1])).eval()  # fails assertion and exits process

Error message:

python3: /home/ricardo/.theano/compiledir_Linux-5.4--generic-x86_64-with-glibc2.29-x86_64-3.8.5-64/tmpci20dxir/mod.cpp:240: double GammaQ(double, double): Assertion `(n > 0) && (x >= 0)' failed.

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