Issue: _base_score should raise ValueError for points outside support, not return 0.0
Location: exponential.py, uniform.py, normal.py function _base_score
Problem:
Currently, for points outside the support of the exponential distribution, the function returns 0.0 instead of raising an exception. This is incorrect because:
- The gradient is undefined (does not exist) for such points.
- Returning
0.0 silently hides the error and can mislead downstream calculations
Expected behaviour:
When any element of x is outside the distribution’s support, the function must raise a ValueError (or RuntimeError) indicating that the score is undefined for those points.
Proposed fix:
Replace the np.where with an explicit check:
if np.any(x < 0):
raise ValueError(f"Score is undefined for x < 0 (outside support). Got x = {x}")
grad = 1.0 / lam - x
return grad[..., np.newaxis]
Issue:
_base_scoreshould raiseValueErrorfor points outside support, not return 0.0Location:
exponential.py,uniform.py,normal.pyfunction_base_scoreProblem:
Currently, for points outside the support of the exponential distribution, the function returns
0.0instead of raising an exception. This is incorrect because:0.0silently hides the error and can mislead downstream calculationsExpected behaviour:
When any element of
xis outside the distribution’s support, the function must raise aValueError(orRuntimeError) indicating that the score is undefined for those points.Proposed fix:
Replace the
np.wherewith an explicit check: