Class MarsagliaTsang2000

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

public class MarsagliaTsang2000 extends Object implements RandomGammaGenerator
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 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 parameter
      theta - the scale parameter
      normal - a standard normal random number generator
      uniform - 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 parameter
      theta - 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.
      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