Class XiTanLiu2010b
java.lang.Object
dev.nm.stat.random.rng.univariate.gamma.XiTanLiu2010b
- 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 4.1 in the reference. It restricts the range of the shape
parameter to be equal to or less than 1.
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
ConstructorsConstructorDescriptionXiTanLiu2010b
(double k) Construct a random number generator to sample from the gamma distribution.XiTanLiu2010b
(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
-
XiTanLiu2010b
Construct a random number generator to sample from the gamma distribution.- Parameters:
k
- the shape parameteruniform
- a uniform random number generator
-
XiTanLiu2010b
public XiTanLiu2010b(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
-