ContinuousSampler, SharedStateContinuousSampler, SharedStateSampler<SharedStateContinuousSampler>public class AhrensDieterMarsagliaTsangGammaSampler extends SamplerBase implements SharedStateContinuousSampler
0 < alpha < 1:
Ahrens, J. H. and Dieter, U., Computer methods for sampling from gamma, beta, Poisson and binomial distributions, Computing, 12, 223-246, 1974.
alpha >= 1:
Marsaglia and Tsang, A Simple Method for Generating Gamma Variables. ACM Transactions on Mathematical Software, Volume 26 Issue 3, September, 2000.
Sampling uses:
UniformRandomProvider.nextDouble() (both algorithms)
UniformRandomProvider.nextLong() (only for alpha >= 1)
| Constructor | Description |
|---|---|
AhrensDieterMarsagliaTsangGammaSampler(org.apache.commons.rng.UniformRandomProvider rng,
double alpha,
double theta) |
This instance delegates sampling.
|
| Modifier and Type | Method | Description |
|---|---|---|
static SharedStateContinuousSampler |
of(org.apache.commons.rng.UniformRandomProvider rng,
double alpha,
double theta) |
Creates a new gamma distribution sampler.
|
double |
sample() |
Creates a sample.
|
java.lang.String |
toString() |
|
SharedStateContinuousSampler |
withUniformRandomProvider(org.apache.commons.rng.UniformRandomProvider rng) |
Create a new instance of the sampler with the same underlying state using the given
uniform random provider as the source of randomness.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitnextDouble, nextInt, nextInt, nextLongpublic AhrensDieterMarsagliaTsangGammaSampler(org.apache.commons.rng.UniformRandomProvider rng, double alpha, double theta)
of(UniformRandomProvider, double, double) to create an optimal sampler.rng - Generator of uniformly distributed random numbers.alpha - Alpha parameter of the distribution (this is a shape parameter).theta - Theta parameter of the distribution (this is a scale parameter).java.lang.IllegalArgumentException - if alpha <= 0 or theta <= 0public double sample()
sample in interface ContinuousSamplerpublic java.lang.String toString()
toString in class SamplerBasepublic SharedStateContinuousSampler withUniformRandomProvider(org.apache.commons.rng.UniformRandomProvider rng)
withUniformRandomProvider in interface SharedStateSampler<SharedStateContinuousSampler>rng - Generator of uniformly distributed random numbers.public static SharedStateContinuousSampler of(org.apache.commons.rng.UniformRandomProvider rng, double alpha, double theta)
rng - Generator of uniformly distributed random numbers.alpha - Alpha parameter of the distribution (this is a shape parameter).theta - Theta parameter of the distribution (this is a scale parameter).java.lang.IllegalArgumentException - if alpha <= 0 or theta <= 0Copyright © 2016–2019 The Apache Software Foundation. All rights reserved.