DiscreteUniform.logcdf is -inf at the lower bound
Author: anishmehta24Created Sep 24, 2026Updated Sep 24, 2026
Describe the issue:
DiscreteUniform.logcdf returns -inf at value == lower, but P(X <= lower) = 1 / (upper - lower + 1). The switch uses pt.le(value, lower) where it should use pt.lt.
This also affects Censored at the lower bound: the logp of an observation censored at lower comes out as -inf.
Reproduceable code example:
import numpy as np
import pymc as pm
import scipy.stats as st
print(np.exp(pm.logcdf(pm.DiscreteUniform.dist(1, 4), np.array([0, 1, 2, 3, 4])).eval()))
# [0. 0. 0.5 0.75 1. ]
print(st.randint(1, 5).cdf([0, 1, 2, 3, 4]))
# [0. 0.25 0.5 0.75 1. ]
print(pm.logp(pm.Censored.dist(pm.DiscreteUniform.dist(0, 3), lower=0, upper=None), 0).eval())
# -inf, expected log(0.25)Error message:
No error, wrong value.PyMC version information:
PyMC main (3f3b108), Windows 11, Python 3.12
Context for the issue:
The existing check_logcdf test doesn't hit value == lower, which is probably why this wasn't caught. I have a fix with a test ready and will open a PR.
Source: pymc-devs/pymc