BUG: Moyal logcdf returns -inf in lower tail where value is finite
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 76/100
Research direction
Start at pymc.distributions.continuous.Moyal.logcdf and run the reproduction with the listed lower-tail values. Inspect the existing logcdf expression and related distribution tests; done means finite results for values such as -50 that agree with scipy.stats.moyal.logcdf without regressing ordinary inputs.
Written by the indexing model from the issue text.
Description
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:
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:
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.
- Dominant language
- Python
- Stars
- 9.8k
- Forks
- 2.3k
- Avg merge
- 21h 39m
- Merged PRs (30d)
- 5
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from pymc-devs/pymc
-
Difficulty 1/5 Under an hour Newbie friendliness 95/100
-
docs
Difficulty 2/5 1-3 hours Newbie friendliness 83/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100