RFR: JDK-8273056 java.util.random does not correctly sample exponential or Gaussian distributions

Jim Laskey jlaskey at openjdk.java.net
Thu Nov 11 14:09:50 UTC 2021


The modified ziggurat algorithm is not correctly implemented in `java.base/jdk/internal/util/random/RandomSupport.java`. 

Create a histogram of a million samples using 2000 uniform bins with the following range: 
Exponential range from 0 to 12. Gaussian range from -8 to 8. 

This does not pass a Chi-square test. If you look at the histogram it is obviously not showing the shape of the PDF for these distributions. Look closely at the range around zero (e.g. +/- 0.5).

-------------

Commit messages:
 - 8273056 - java.util.random does not correctly sample exponential or Gaussian distributions

Changes: https://git.openjdk.java.net/jdk/pull/6353/files
 Webrev: https://webrevs.openjdk.java.net/?repo=jdk&pr=6353&range=00
  Issue: https://bugs.openjdk.java.net/browse/JDK-8273056
  Stats: 15 lines in 1 file changed: 6 ins; 4 del; 5 mod
  Patch: https://git.openjdk.java.net/jdk/pull/6353.diff
  Fetch: git fetch https://git.openjdk.java.net/jdk pull/6353/head:pull/6353

PR: https://git.openjdk.java.net/jdk/pull/6353


More information about the core-libs-dev mailing list