jax
jax copied to clipboard
jax.scipy.stats.pareto returns -inf/inf/nan at the support boundary when scale is small relative to loc (support mask computed on unstandardized x)
Description
Description
The Pareto functions decide whether x is in the support with x < loc + scale, but compute the value
from the standardized z = (x - loc) / scale. When scale is below the floating-point resolution of
loc, loc + scale == loc, so x == loc passes the support test while z = 0 is outside the support,
and cdf, sf, pdf, logcdf return -inf, inf, inf, nan instead of 0, 1, 0, -inf.
This happens with ordinary parameters in JAX's default float32 mode.
Steps to reproduce
from jax.scipy.stats import pareto
x, b, loc, scale = 1000.0, 1.0, 1000.0, 1e-5
print([float(f(x, b, loc, scale)) for f in (pareto.cdf, pareto.sf, pareto.pdf, pareto.logcdf)])
# [-inf, inf, inf, nan]; scipy.stats.pareto gives [0.0, 1.0, 0.0, -inf]
Expected
cdf = 0, sf = 1, pdf = 0, logcdf = -inf for x below the support, as in SciPy.
System info (python version, jaxlib version, accelerator, etc.)
Environment
JAX / jaxlib 0.11.2 (the latest release, CPU) and 0.10.1, Python 3.12, Ubuntu 24.04, x86_64
#38651