Quantcast
Channel: How many times can I use randomGenerator.nextDouble() before I need to reseed? - Stack Overflow
Viewing all articles
Browse latest Browse all 4

How many times can I use randomGenerator.nextDouble() before I need to reseed?

$
0
0

I'm using the Random class in Java as a pseudo-random number generator. I'm using the function nextDouble a lot of times (~10^5). How many times before I have to reseed to prevent from getting the same numbers? Is reseeding needed?

    Random generator = new Random();    double[] numbers = new double[n];    for (int i = 0; i < n; i++) numbers[i] = generator.nextDouble();

This is for an experiment, the numbers will be used as coordinates for points on a space, so I want the distribution to be as uniform as possible.

Also how do I reseed? Where do I get the int seed from?


Viewing all articles
Browse latest Browse all 4

Latest Images

Trending Articles



Latest Images