RFR: 8284493: Fix rounding error in computeNextExponential [v4]
Chris Hennick
duke at openjdk.java.net
Mon Jun 6 15:52:43 UTC 2022
> Repeatedly adding DoubleZigguratTables.exponentialX0 to extra causes a rounding error to accumulate at the tail of the distribution (probably starting around 2*exponentialX0 == 0x1.e46eff20739afp3 ~ 15.1); this fixes that by tracking the multiple of exponentialX0 as a long. (This changes the maximum possible output to `1.0p63 * DoubleZigguratTables.exponentialX0 == 0x1.e46eff20739afp65`; previously it would have been `0x1.0p56` because once `extra` reaches that amount, `x + extra == extra` due to the rounding error. This lowers the probability of reaching the maximum with an ideal PRNG from about `1.3877787807814488E-17` to about `1.4323726067488646E-20` (calculated using the identity `ln(x) == Math.log10(x)/Math.log10(Math.exp(1))`).
Chris Hennick has updated the pull request with a new target base due to a merge or a rebase. The incremental webrev excludes the unrelated changes brought in by the merge/rebase. The pull request contains three additional commits since the last revision:
- Merge branch 'openjdk:master' into patch-1
- Merge branch 'openjdk:master' into patch-1
- Fix rounding error in computeNextExponential; use FMA
Repeatedly adding DoubleZigguratTables.exponentialX0 to extra causes a rounding error to accumulate at the tail of the distribution; this fixes that by tracking the multiple of exponentialX0 as a long.
Add computeWinsorizedNextExponential for testability
-------------
Changes:
- all: https://git.openjdk.java.net/jdk/pull/8131/files
- new: https://git.openjdk.java.net/jdk/pull/8131/files/c5a28f98..1daaadac
Webrevs:
- full: https://webrevs.openjdk.java.net/?repo=jdk&pr=8131&range=03
- incr: https://webrevs.openjdk.java.net/?repo=jdk&pr=8131&range=02-03
Stats: 1548 lines in 42 files changed: 1399 ins; 60 del; 89 mod
Patch: https://git.openjdk.java.net/jdk/pull/8131.diff
Fetch: git fetch https://git.openjdk.java.net/jdk pull/8131/head:pull/8131
PR: https://git.openjdk.java.net/jdk/pull/8131
More information about the core-libs-dev
mailing list