Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JDK-8273056 java.util.random does not correctly sample exponential or Gaussian distributions #6353

Closed
wants to merge 2 commits into from

Conversation

JimLaskey
Copy link
Member

@JimLaskey JimLaskey commented Nov 11, 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).


Progress

  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue
  • Change must be properly reviewed

Issue

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

Reviewers

Contributors

  • Guy Steele <gls@openjdk.org>

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.java.net/jdk pull/6353/head:pull/6353
$ git checkout pull/6353

Update a local copy of the PR:
$ git checkout pull/6353
$ git pull https://git.openjdk.java.net/jdk pull/6353/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 6353

View PR using the GUI difftool:
$ git pr show -t 6353

Using diff file

Download this PR as a diff file:
https://git.openjdk.java.net/jdk/pull/6353.diff

@JimLaskey
Copy link
Member Author

/contributor add gls

@bridgekeeper
Copy link

bridgekeeper bot commented Nov 11, 2021

👋 Welcome back jlaskey! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk openjdk bot added the rfr Pull request is ready for review label Nov 11, 2021
@openjdk
Copy link

openjdk bot commented Nov 11, 2021

@JimLaskey
Contributor Guy Steele <gls@openjdk.org> successfully added.

@openjdk
Copy link

openjdk bot commented Nov 11, 2021

@JimLaskey The following label will be automatically applied to this pull request:

  • core-libs

When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing list. If you would like to change these labels, use the /label pull request command.

@openjdk openjdk bot added the core-libs core-libs-dev@openjdk.org label Nov 11, 2021
@mlbridge
Copy link

mlbridge bot commented Nov 11, 2021

Webrevs

@JimLaskey
Copy link
Member Author

Still waiting for a review on these changes.

for (;; U1 = (rng.nextLong() >>> 1)) {
// At this point, the high-order bits of U1 have not been used yet,
// but we need the value in U1 to be positive.
for (U1 = (U1 >>> 1);; U1 = (rng.nextLong() >>> 1)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A minor thing, but I would probably write U1 >>>= 1 instead of U1 = (U1 >>> 1).

Copy link
Member

@bplb bplb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks fine.

@openjdk
Copy link

openjdk bot commented Nov 30, 2021

@JimLaskey This change now passes all automated pre-integration checks.

ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details.

After integration, the commit message for the final commit will be:

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

Co-authored-by: Guy Steele <gls@openjdk.org>
Reviewed-by: bpb, darcy

You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed.

At the time when this comment was updated there had been no new commits pushed to the master branch. If another commit should be pushed before you perform the /integrate command, your PR will be automatically rebased. If you prefer to avoid any potential automatic rebasing, please check the documentation for the /integrate command for further details.

➡️ To integrate this PR with the above commit message to the master branch, type /integrate in a new comment.

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Nov 30, 2021
@jddarcy
Copy link
Member

jddarcy commented Nov 30, 2021

Should there be a regression test here?

@JimLaskey
Copy link
Member Author

JimLaskey commented Dec 1, 2021

Should there be a regression test here?

I can ask the submitter to provide a new test based on his testing (new JBS issue.) The complexity of the test is beyond in house expertise.

@jddarcy
Copy link
Member

jddarcy commented Dec 1, 2021

Should there be a regression test here?

I can ask the submitter to provide a new test based on his testing (new JBS issue.) The complexity of the test is beyond in house expertise.

Okay.

@JimLaskey
Copy link
Member Author

/integrate

@openjdk
Copy link

openjdk bot commented Dec 2, 2021

Going to push as commit 3d98ec1.
Since your change was applied there have been 15 commits pushed to the master branch:

  • b79554b: 8278130: Failure in jdk/javadoc/tool/CheckManPageOptions.java after JDK-8274639
  • ea905bd: 8277924: Small tweaks to foreign function and memory API
  • e002bfe: 8278049: G1: add precondition to set_remainder_to_point_to_start
  • 16cfbc4: 8278071: typos in MemorySegment::set, MemorySegment::setAtIndex javadoc
  • 84ca14d: 8277194: applications/runthese/RunThese30M.java crashes with jfrSymbolTable.cpp:305 assert(_instance != null)
  • 103da8f: 8274639: Provide a way to disable warnings for cross-modular links
  • 088b244: 8251216: Implement MD5 intrinsics on AArch64
  • a093cdd: 8276657: XSLT compiler tries to define a class with empty name
  • 8198807: 8266435: WBMPImageReader.read() should not truncate the input stream
  • b226ab9: 8276141: XPathFactory set/getProperty method
  • ... and 5 more: https://git.openjdk.java.net/jdk/compare/a363b7b9217cbb9a7580a87b812da8d5a4215326...master

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot closed this Dec 2, 2021
@openjdk openjdk bot added integrated Pull request has been integrated and removed ready Pull request is ready to be integrated rfr Pull request is ready for review labels Dec 2, 2021
@openjdk
Copy link

openjdk bot commented Dec 2, 2021

@JimLaskey Pushed as commit 3d98ec1.

💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core-libs core-libs-dev@openjdk.org integrated Pull request has been integrated
3 participants