#8437·pymc

BUG: Moyal logcdf returns -inf in lower tail where value is finite

Author: sonusharma6-dsaCreated Sep 14, 2026Updated Sep 14, 2026

Describe the issue:

Moyal.logcdf returns -inf in the lower tail for values where the true logcdf is finite and well within floating-point range.

In pymc.distributions.continuous.Moyal.logcdf:

python
scaled = (value - mu) / sigma
res = pt.log(pt.erfc(pt.exp(-scaled / 2) * (2**-0.5)))

For large negative value, scaled = (value - mu) / sigma becomes a large negative number. pt.exp(-scaled / 2) grows large, causing pt.erfc(...) to underflow to 0.0, resulting in pt.log(0.0) == -inf.

Reproduceable code example:

python
import numpy as np
import pymc as pm
from scipy import stats

rv = pm.Moyal.dist(mu=0.0, sigma=1.0)
xs = np.array([-10.0, -20.0, -50.0])

print("PyMC logcdf :", pm.logcdf(rv, xs).eval())
print("SciPy logcdf:", stats.moyal.logcdf(xs, loc=0.0, scale=1.0))

Error message:

No exception is raised. logcdf returns -inf for large negative values (e.g. xs = -50.0) where SciPy reports a finite log-probability value.

PyMC version information:

Environment
  • PyMC version: 5.x / 6.x (main branch)
  • PyTensor version: 3.x
  • Python version: 3.11+
  • OS: Windows / Linux / macOS

Context for the issue:

logcdf is used in censored and truncated distribution models (pm.Censored, pm.Truncated). When logcdf prematurely returns -inf in the lower tail, sampling or model evaluation fails with invalid log-probabilities.