Class RNGDistribution.Exponential

Object
RNGDistribution
Exponential
Enclosing class:
RNGDistribution

public static class RNGDistribution.Exponential extends RNGDistribution
Exponentially distributed random numbers with support [0.0, Double.MAX_VALUE).
See Also:
  • Field Details

    • mean

      private double mean
      The mean of exponential distribution.
  • Constructor Details

    • Exponential

      public Exponential()
      Creates exponential distribution with mean==1 and a new instance of MersenneTwister.
    • Exponential

      public Exponential(double mean)
      Creates exponential distribution with mean and a new instance of MersenneTwister.
      Parameters:
      mean - the mean of the exponential distribution
    • Exponential

      public Exponential(MersenneTwister rng, double mean) throws IllegalArgumentException
      Creates exponential distribution with mean and random number generator rng.
      Parameters:
      rng - the random number generator
      mean - the mean of the exponential distribution
      Throws:
      IllegalArgumentException - if man≤0
      See Also:
  • Method Details

    • getMean

      public double getMean()
      Get the mean of the exponential distribution.
      Returns:
      the mean
    • next

      public double next()
      Generate an exponentially distributed random number with mean.
      Returns:
      the exponentially distributed random number
    • clone

      Description copied from class: RNGDistribution
      Clone this RNGDistribution to ensure both objects return identical sequences of random numbers.

      IMPORTANT:

      1. overrides clone() in Object but conflicts with GWT's aversion to clone()ing...
      2. remove @SuppressWarnings("all") to ensure that no other issues crept in when modifying method.
      Specified by:
      clone in class RNGDistribution
      Returns:
      clone of RNGDistribution
    • next

      public static double next(MersenneTwister rng, double mean)
      Exponentially distributed random number with mean using random number generator rng.

      Note: no performance difference between the instance method next() and this static counterpart.

      Parameters:
      rng - random number generator
      mean - of exponential distribution
      Returns:
      exponentially distributed random number with mean
      Throws:
      IllegalArgumentException - if man≤0
    • test

      public static void test(MersenneTwister rng, Logger logger, MersenneTwister.Chronometer clock)
      Test Exponential distribution.

      The test samples the distribution and bins the random numbers. This sample distribution is compared to the theoretical expectation. The mean deviation is the mean difference between the actual number of events in each bin and their expected number. For a perfect match the mean deviation is 0. The test passes if the mean deviation lies within one standard error from 0. This is more stringent than the traditional 95% confidence interval.

      Parameters:
      rng - the random number generator
      logger - the logger for reporting results
      clock - the stop watch
      See Also:
    • cdf

      private static double cdf(double x, double mean)
      Helper method to calculate the cumulative distribution function, cdf, of the Exponential distribution.
      Parameters:
      x - the value for which to calculate the cdf
      mean - the mean value
      Returns:
      cdf at x