RFR: 8326227: Rounding error that may distort computeNextGaussian results [v10]
Chris Hennick
duke at openjdk.org
Sat Aug 10 03:22:34 UTC 2024
On Sat, 10 Aug 2024 03:00:10 GMT, Chris Hennick <duke at openjdk.org> wrote:
>> This provides a slightly more accurate bounding limit for `computeNextExponentialSoftCapped`. Currently, if the maximum is specified as 12.0, it won't actually return a value larger than `1.5 * exponentialX0` (11.353912041222094); and the error gets worse as we go further into the tail. (This affects slightly less than 12 outputs per million for an ideal RNG.) This could cause the `while (computeNextExponentialSoftCapped(rng, limit) < limit)` check in `computeNextGaussian` on line 1402 to always be true, making the `nextGaussian` runtime unbounded in the worst case; but more likely, it would give a result that was truncated too close to zero.
>>
>> This change is being tested prior to submission to OpenJDK by https://github.com/openjdk/jdk/pull/17703/commits/b8be051cbf40a6a05fafc6a2c76942e9e0b11fdf.
>
> Chris Hennick has updated the pull request incrementally with one additional commit since the last revision:
>
> Fix: must add 1 *after* dividing
@GuySteele Thanks for your earlier feedback; I've now verified the problem and quantified the rate at which `computeNextExponential` is affected.
-------------
PR Comment: https://git.openjdk.org/jdk/pull/17703#issuecomment-2278958913
More information about the core-libs-dev
mailing list