Java – before I need to reset, I can use randomgenerator How many times does nextdouble()?
•
Java
I use the random class in Java as a pseudo - random number generator I am using the function nextdouble many times (~ 10 ^ 5) How many times do I need to replay to prevent getting the same number? Does it need to be replanted?
Random generator = new Random(); double[] numbers = new double[n]; for (int i = 0; i < n; i++) numbers[i] = generator.nextDouble();
This is an experiment. Numbers will be used as coordinates of points in space, so I want to distribute them as evenly as possible
How can I replant? Where do I get int seeds?
Solution
The random number generator generates a random double from two random int values The internal seed has 48 bits, so the random sequence repeats after up to 2 ^ 48 int values or 2 ^ 47 double values
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码