This transcript shows how Claude identifies a bug in
numpy.random.wald by inferring properties from documentation and tests, then using Hypothesis to
find counterexamples.
Target: numpy.random.wald
Severity: High
Bug Type: Logic
Date: 2025-09-15
The numpy.random.wald function produces zero values when given certain valid
parameter combinations, violating the mathematical property that the Wald distribution only
produces positive values.
Failing input: mean=265150.0, scale=0.00390625, size=1
Output:
The Wald (inverse Gaussian) distribution is mathematically defined to produce only positive values. Its probability density function is:
This PDF is only defined for x > 0. Producing zero values violates this fundamental property of the distribution and can cause downstream issues in applications that rely on this mathematical guarantee.
The issue likely occurs due to numerical underflow or improper handling of extreme parameter ratios. The implementation should ensure that:
A potential fix would involve checking the output and replacing any zero or negative values with the smallest positive float value, or adjusting the internal algorithm to prevent underflow.