Package weka.core

# Class RandomVariates

java.lang.Object
java.util.Random
weka.core.RandomVariates

All Implemented Interfaces:
  `Serializable`, `RandomGenerator`, `RevisionHandler`

public final class RandomVariates extends Random implements RevisionHandler
Class implementing some simple random variates generator.

Version:
  $Revision: 8034 $
Author:
  Xin Xu (xx5@cs.waikato.ac.nz)
See Also:
  - Serialized Form

- ## Nested Class Summary

  ## Nested classes/interfaces inherited from interface java.util.random.RandomGenerator

  `RandomGenerator.ArbitrarilyJumpableGenerator, RandomGenerator.JumpableGenerator, RandomGenerator.LeapableGenerator, RandomGenerator.SplittableGenerator, RandomGenerator.StreamableGenerator`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `RandomVariates()`
  Simply the constructor of super class
  `RandomVariates(long seed)`
  Simply the constructor of super class

- ## Method Summary

  Modifier and Type
  Method
  Description
  `String`
  `getRevision()`
  Returns the revision string.
  `static void`
  `main(String[] ops)`
  Main method for testing this class.
  `double`
  `nextErlang(int a)`
  Generate a value of a variate following standard Erlang distribution.
  `double`
  `nextExponential()`
  Generate a value of a variate following standard exponential distribution using simple inverse method.
  `double`
  `nextGamma(double a)`
  Generate a value of a variate following standard Gamma distribution with shape parameter a.

  ### Methods inherited from class java.util.Random

  `doubles, doubles, doubles, doubles, ints, ints, ints, ints, longs, longs, longs, longs, nextBoolean, nextBytes, nextDouble, nextFloat, nextGaussian, nextInt, nextInt, nextLong, setSeed`

  ### Methods inherited from class java.lang.Object

  `equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

  ### Methods inherited from interface java.util.random.RandomGenerator

  `isDeprecated, nextDouble, nextDouble, nextFloat, nextFloat, nextGaussian, nextInt, nextLong, nextLong`

- ## Constructor Details

  - ### RandomVariates

    public RandomVariates()
    Simply the constructor of super class

  - ### RandomVariates

    public RandomVariates(long seed)
    Simply the constructor of super class
    Parameters:
      `seed` - the seed in this random object

- ## Method Details

  - ### nextExponential

    public double nextExponential()
    Generate a value of a variate following standard exponential distribution using simple inverse method.

    Variates related to standard Exponential can be generated using simple transformations.

    Specified by:
      `nextExponential` in interface `RandomGenerator`
    Returns:
      a value of the variate

  - ### nextErlang

    public double nextErlang(int a) throws Exception
    Generate a value of a variate following standard Erlang distribution. It can be used when the shape parameter is an integer and not too large, say, <100. When the parameter is not an integer (which is often named Gamma distribution) or is large, use `nextGamma(double a)` instead.
    Parameters:
      `a` - the shape parameter, must be no less than 1
    Returns:
      a value of the variate
    Throws:
      `Exception` - if parameter less than 1

  - ### nextGamma

    public double nextGamma(double a) throws Exception
    Generate a value of a variate following standard Gamma distribution with shape parameter a.

    If a>1, it uses a rejection method developed by Minh(1988)"Generating Gamma Variates", ACM Trans. on Math. Software, Vol.14, No.3, pp261-266.
    If a<1, it uses the algorithm "GS" developed by Ahrens and Dieter(1974) "COMPUTER METHODS FOR SAMPLING FROM GAMMA, BETA, POISSON AND BINOMIAL DISTRIBUTIONS", COMPUTING, 12 (1974), pp223-246, and further implemented in Fortran by Ahrens, Kohrt and Dieter(1983) "Algorithm 599: sampling from Gamma and Poisson distributions", ACM Trans. on Math. Software, Vol.9 No.2, pp255-257.

    Variates related to standard Gamma can be generated using simple transformations.

    Parameters:
      `a` - the shape parameter, must be greater than 1
    Returns:
      a value of the variate
    Throws:
      `Exception` - if parameter not greater than 1

  - ### getRevision

    public String getRevision()
    Returns the revision string.
    Specified by:
      `getRevision` in interface `RevisionHandler`
    Returns:
      the revision

  - ### main

    public static void main(String[] ops)
    Main method for testing this class.
    Parameters:
      `ops` - # of variates/seed, default is 10/45