Class XiTanLiu2010a

java.lang.Object
dev.nm.stat.random.rng.univariate.gamma.XiTanLiu2010a
All Implemented Interfaces:
RandomGammaGenerator, RandomNumberGenerator, Seedable

public class XiTanLiu2010a extends Object implements RandomGammaGenerator
Xi, Tan and Liu proposed two simple algorithms to generate gamma random numbers based on the ratio-of-uniforms method and logarithmic transformations of gamma random variable. This implementation is Algorithm 3.1 in the reference. It does not restrict the range of the shape parameter. It, however, assumes the scale parameter is always 1. Note that for when the shape parameter < 0.01, it returns numbers in logarithmic scale. Take exp to convert.
  • Constructor Summary

    Constructors
    Constructor
    Description
    XiTanLiu2010a(double k)
    Construct a random number generator to sample from the gamma distribution.
    XiTanLiu2010a(double k, RandomLongGenerator uniform)
    Construct a random number generator to sample from the gamma distribution.
  • Method Summary

    Modifier and Type
    Method
    Description
    double
    Get the next random double.
    void
    seed(long... seeds)
    Seed the random number/vector/scenario generator to produce repeatable experiments.

    Methods inherited from class java.lang.Object

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

    • XiTanLiu2010a

      public XiTanLiu2010a(double k, RandomLongGenerator uniform)
      Construct a random number generator to sample from the gamma distribution.
      Parameters:
      k - the shape parameter
      uniform - a uniform random number generator
    • XiTanLiu2010a

      public XiTanLiu2010a(double k)
      Construct a random number generator to sample from the gamma distribution.
      Parameters:
      k - the shape parameter
  • Method Details

    • seed

      public void seed(long... seeds)
      Description copied from interface: Seedable
      Seed the random number/vector/scenario generator to produce repeatable experiments.
      Specified by:
      seed in interface Seedable
      Parameters:
      seeds - the seeds
    • nextDouble

      public double nextDouble()
      Description copied from interface: RandomNumberGenerator
      Get the next random double.
      Specified by:
      nextDouble in interface RandomNumberGenerator
      Returns:
      the next random number