Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8302987 Add uniform and spatially equidistributed bounded double streams to RandomGenerator
  3. JDK-8316899

Release Note: Add `equiDoubles()` Method to `java.util.random.RandomGenerator`.

    XMLWordPrintable

Details

    • In Review
    • 22

    Description

      A new method, `equiDoubles()`, has been added to `java.util.random.RandomGenerator`.

      `equiDoubles()` guarantees a uniform distribution, provided the underlying `nextLong(long)` method returns uniformly distributed values, that is as dense as possible. It returns a `DoubleStream` rather than individual `double`s because of slightly expensive initial computations. They are better absorbed as setup costs for the stream rather than being repeated for each new computed value.

      The aim is to overcome some numerical limitations in the families of `doubles()` and `nextDouble()` methods. In these, an affine transform is applied to a uniformly distributed pseudo-random value in the half-open interval [0.0, 1.0) to obtain a pseudo-random value in the half-open interval [origin, bound). However, due to the nature of floating-point arithmetic, the affine transform ends up in a slightly distorted distribution, which is not necessarily uniform.

      Attachments

        Activity

          People

            rgiulietti Raffaello Giulietti
            rgiulietti Raffaello Giulietti
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: