Class PolarGaussian

java.lang.Object
org.cicirello.math.rand.PolarGaussian

public final class PolarGaussian extends Object

This class provides methods for generating pseudorandom numbers from a Gaussian distribution using the classic Polar Method. Other methods exist that are faster than Polar, and with superior statistical properties over the Polar method. One such algorithm is the Ziggurat method, implemented in the ZigguratGaussian class. The Polar method implementation provided in the PolarGaussian class was originally implemented as part of an experimental study comparing the effects of different Gaussian algorithms on the performance of a genetic algorithm. It is included here in this repository, however, if you are looking for a fast algorithm for generating Gaussian distributed random numbers, we suggest you consider the ZigguratGaussian class instead.

You can find some experimental data comparing the performance of a sequential genetic algorithm (GA) using this implementation of the Polar method for Gaussian mutation vs using the faster Ziggurat method, as well as experimental data for the same comparison but with a Parallel GA, in the following paper:

  • Method Summary

    Modifier and Type
    Method
    Description
    static double
    Generates a random number from a Gaussian distribution with mean 0 and standard deviation 1.
    static double
    nextGaussian(double sigma)
    Generates a random number from a Gaussian distribution with mean 0 and standard deviation, sigma, or your choosing.
    static double
    nextGaussian(double sigma, RandomGenerator r)
    Generates a random number from a Gaussian distribution with mean 0 and standard deviation, sigma, or your choosing.
    static double
    Generates a random number from a Gaussian distribution with mean 0 and standard deviation 1.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • nextGaussian

      public static double nextGaussian(double sigma)
      Generates a random number from a Gaussian distribution with mean 0 and standard deviation, sigma, or your choosing. ThreadLocalRandom is used as the pseudorandom number generator for the source of randomness.
      Parameters:
      sigma - The standard deviation of the Gaussian.
      Returns:
      A random number from a Gaussian distribution with mean 0 and standard deviation sigma.
    • nextGaussian

      public static double nextGaussian(double sigma, RandomGenerator r)
      Generates a random number from a Gaussian distribution with mean 0 and standard deviation, sigma, or your choosing.
      Parameters:
      sigma - The standard deviation of the Gaussian.
      r - The pseudorandom number generator to use for the source of randomness.
      Returns:
      A random number from a Gaussian distribution with mean 0 and standard deviation sigma.
    • nextGaussian

      public static double nextGaussian()
      Generates a random number from a Gaussian distribution with mean 0 and standard deviation 1. ThreadLocalRandom is used as the pseudorandom number generator for the source of randomness.
      Returns:
      A random number from a Gaussian distribution with mean 0 and standard deviation 1.
    • nextGaussian

      public static double nextGaussian(RandomGenerator r)
      Generates a random number from a Gaussian distribution with mean 0 and standard deviation 1.
      Parameters:
      r - The pseudorandom number generator to use for the source of randomness.
      Returns:
      A random number from a Gaussian distribution with mean 0 and standard deviation 1.