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
All Methods Instance Methods Concrete Methods Modifier and Type Method Description doublenextDouble()Get the next randomdouble.voidseed(long... seeds)Seed the random number/vector/scenario generator to produce repeatable experiments.
-
-
-
Constructor Detail
-
XiTanLiu2010a
public XiTanLiu2010a(double k, RandomLongGenerator uniform)Construct a random number generator to sample from the gamma distribution.- Parameters:
k- the shape parameteruniform- 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 Detail
-
seed
public void seed(long... seeds)
Description copied from interface:SeedableSeed the random number/vector/scenario generator to produce repeatable experiments.
-
nextDouble
public double nextDouble()
Description copied from interface:RandomNumberGeneratorGet the next randomdouble.- Specified by:
nextDoublein interfaceRandomNumberGenerator- Returns:
- the next random number
-
-