Class AhrensDieterMarsagliaTsangGammaSampler.AhrensDieterGammaSampler
java.lang.Object
org.apache.commons.rng.sampling.distribution.AhrensDieterMarsagliaTsangGammaSampler.BaseGammaSampler
org.apache.commons.rng.sampling.distribution.AhrensDieterMarsagliaTsangGammaSampler.AhrensDieterGammaSampler
- All Implemented Interfaces:
ContinuousSampler,SharedStateContinuousSampler,SharedStateSampler<SharedStateContinuousSampler>
- Enclosing class:
AhrensDieterMarsagliaTsangGammaSampler
private static final class AhrensDieterMarsagliaTsangGammaSampler.AhrensDieterGammaSampler
extends AhrensDieterMarsagliaTsangGammaSampler.BaseGammaSampler
Class to sample from the Gamma distribution when
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.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final doubleOptimization (see code).private final doubleInverse of "alpha".Fields inherited from class org.apache.commons.rng.sampling.distribution.AhrensDieterMarsagliaTsangGammaSampler.BaseGammaSampler
alpha, rng, theta -
Constructor Summary
ConstructorsConstructorDescriptionAhrensDieterGammaSampler(UniformRandomProvider rng, double alpha, double theta) AhrensDieterGammaSampler(UniformRandomProvider rng, AhrensDieterMarsagliaTsangGammaSampler.AhrensDieterGammaSampler source) -
Method Summary
Modifier and TypeMethodDescriptiondoublesample()Creates adoublesample.Create a new instance of the sampler with the same underlying state using the given uniform random provider as the source of randomness.Methods inherited from class org.apache.commons.rng.sampling.distribution.AhrensDieterMarsagliaTsangGammaSampler.BaseGammaSampler
toStringMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.apache.commons.rng.sampling.distribution.ContinuousSampler
samples, samples
-
Field Details
-
oneOverAlpha
private final double oneOverAlphaInverse of "alpha". -
bGSOptim
private final double bGSOptimOptimization (see code).
-
-
Constructor Details
-
AhrensDieterGammaSampler
AhrensDieterGammaSampler(UniformRandomProvider rng, double alpha, double theta) - Parameters:
rng- Generator of uniformly distributed random numbers.alpha- Alpha parameter of the distribution.theta- Theta parameter of the distribution.- Throws:
IllegalArgumentException- ifalpha <= 0ortheta <= 0
-
AhrensDieterGammaSampler
AhrensDieterGammaSampler(UniformRandomProvider rng, AhrensDieterMarsagliaTsangGammaSampler.AhrensDieterGammaSampler source) - Parameters:
rng- Generator of uniformly distributed random numbers.source- Source to copy.
-
-
Method Details
-
sample
public double sample()Description copied from interface:ContinuousSamplerCreates adoublesample.- Returns:
- a sample.
-
withUniformRandomProvider
Description copied from interface:SharedStateSamplerCreate a new instance of the sampler with the same underlying state using the given uniform random provider as the source of randomness.- Parameters:
rng- Generator of uniformly distributed random numbers.- Returns:
- the sampler
-