Class XiTanLiu2010a
java.lang.Object
dev.nm.stat.random.rng.univariate.gamma.XiTanLiu2010a
- All Implemented Interfaces:
RandomGammaGenerator
,RandomNumberGenerator
,Seedable
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
ConstructorsConstructorDescriptionXiTanLiu2010a
(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 TypeMethodDescriptiondouble
Get the next randomdouble
.void
seed
(long... seeds) Seed the random number/vector/scenario generator to produce repeatable experiments.
-
Constructor Details
-
XiTanLiu2010a
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 Details
-
seed
public void seed(long... seeds) Description copied from interface:Seedable
Seed the random number/vector/scenario generator to produce repeatable experiments. -
nextDouble
public double nextDouble()Description copied from interface:RandomNumberGenerator
Get the next randomdouble
.- Specified by:
nextDouble
in interfaceRandomNumberGenerator
- Returns:
- the next random number
-