Random nextGaussian() in Java

nextGaussian(): This method is available in java.util.Random class of Java.

Syntax:

double java.util.Random.nextGaussian()

This method returns the next pseudorandom, Gaussian ("normally") distributed double value with mean 0.0 and standard deviation 1.0 from this random number generator's sequence.

Parameters: NA

Returns: the next pseudorandom, Gaussian ("normally") distributed double value with mean 0.0 and standard deviation 1.0 from this random number generator's sequence.

Exceptions: NA

Approach

Java

import java.util.Random;

public class RandomnextGaussian {
    public static void main(String[] args) {

        Random random = new Random();

        System.out.println(random.nextGaussian());
    }
}

Output:

1.2589269585018656


No comments:

Post a Comment