Re: Random.nextLong(long bound)?

2017-10-19 Thread Andrew Haley
On 18/10/17 22:54, Steven Schlansker wrote: > Given a long L1 which can be generated and L2 which cannot, it seems > trivial that P(L1) != P(L2) and therefore it is not a uniformly > distributed long value. Am I misunderstanding this concept? I think it's OK. The result of nextLong() is

Re: Random.nextLong(long bound)?

2017-10-19 Thread Dawid Weiss
Hi Steven, > We were hoping to have a single sequence shared between the library that > takes Random and our > own code that hopes to generate bounded longs. We want such tight control > because we are writing > a repeatable tester and want to use the seed to be able to replay sequences >

Re: Random.nextLong(long bound)?

2017-10-18 Thread Steven Schlansker
> On Oct 18, 2017, at 3:15 PM, Martin Buchholz wrote: > > Why not SplittableRandom? > https://docs.oracle.com/javase/9/docs/api/java/util/SplittableRandom.html#nextLong-long- In this particular case, an algorithm written by a library vendor takes a parameter of type

Re: Random.nextLong(long bound)?

2017-10-18 Thread Martin Buchholz
Why not SplittableRandom? https://docs.oracle.com/javase/9/docs/api/java/util/SplittableRandom.html#nextLong-long- On Wed, Oct 18, 2017 at 2:54 PM, Steven Schlansker < stevenschlans...@gmail.com> wrote: > My coworker is implementing an algorithm for which he needs a bounded > random long. > He

Re: Random.nextLong(long bound)?

2017-10-18 Thread Vitaly Davidovich
On Wed, Oct 18, 2017 at 5:54 PM Steven Schlansker < stevenschlans...@gmail.com> wrote: > My coworker is implementing an algorithm for which he needs a bounded > random long. > He needs to be in full control of the seed and not share the instance > (i.e. not use ThreadLocalRandom). > > Random

Random.nextLong(long bound)?

2017-10-18 Thread Steven Schlansker
My coworker is implementing an algorithm for which he needs a bounded random long. He needs to be in full control of the seed and not share the instance (i.e. not use ThreadLocalRandom). Random helpfully provides a nextInt(int bound) but nextLong has no such overload. The code to do so is not