News for hackers. Stuff that matters.
Re:State of the art of random double generation by twic on Friday April 10, 2015 @09:59AM (#9354293)
It's no better in Java. A fairly literal translation of the code [1], using the new Random::doubles method [2], gets counts like so:

  166808
  332743
  500449
If anything, this is even weirder than the C++ results. :rage1:

The doubles method makes each value "as if it's the result of calling the following method with the origin and bound':

  double nextDouble(double origin, double bound) {
    double r = nextDouble();
    r = r * (bound - origin) + origin;
    if (r >= bound) // correct for rounding
      r = Math.nextDown(bound);
    return r;
  }
Which is the naive approach that Artur has been struggling against.

[1] https://bitbucket.org/snippets/twic/qqEe

[2] https://docs.oracle.com/javase/8/docs/api/java/util/Random.h...

There are no comments on this comment yet.