Class MarsagliaTsang2000
java.lang.Object
dev.nm.stat.random.rng.univariate.gamma.MarsagliaTsang2000
- All Implemented Interfaces:
RandomGammaGenerator
,RandomNumberGenerator
,Seedable
Marsaglia-Tsang is a procedure for generating a gamma variate as the cube of a suitably scaled
normal variate. It is fast and simple, assuming one has a fast way to generate standard normal
variables. This algorithm is (significantly) slowed down for when k < 1 because an extra
uniform rng needs to be generated.
Consider using
KunduGupta2007
instead for k < 1.-
Constructor Summary
ConstructorsConstructorDescriptionConstruct a random number generator to sample from the standard gamma distribution.MarsagliaTsang2000
(double k, double theta) Construct a random number generator to sample from the gamma distribution.MarsagliaTsang2000
(double k, double theta, RandomStandardNormalGenerator normal, 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
-
MarsagliaTsang2000
public MarsagliaTsang2000(double k, double theta, RandomStandardNormalGenerator normal, RandomLongGenerator uniform) Construct a random number generator to sample from the gamma distribution.- Parameters:
k
- the shape parametertheta
- the scale parameternormal
- a standard normal random number generatoruniform
- a uniform random number generator
-
MarsagliaTsang2000
public MarsagliaTsang2000(double k, double theta) Construct a random number generator to sample from the gamma distribution.- Parameters:
k
- the shape parametertheta
- the scale parameter
-
MarsagliaTsang2000
public MarsagliaTsang2000()Construct a random number generator to sample from the standard gamma distribution.
-
-
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
-