mercredi 31 août 2016

Java convert two integers to a double from 1 to 0

I am working with an ISAAC implementation which generates random integers. I need to create a Gaussian value with these integers. First, I need to change them to a double from 0 to 1 though. How can I do this in Java? Here is what I have so far to convert the ints to doubles, but it still needs to be in the normal distribution. I am also using java.util.Random.nextGaussian() logic to convert the double to Gaussian.

public double nextDouble() {
    long l = ((long)(nextInt()) << 32) + nextInt();
    return Double.longBitsToDouble(l);
}

What is the fastest possible way (cpu cycle wise) to do this?




Aucun commentaire:

Enregistrer un commentaire