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 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 double
Optimization (see code).private final double
Inverse 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 TypeMethodDescriptiondouble
sample()
Creates adouble
sample.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
toString
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods 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 <= 0
ortheta <= 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:ContinuousSampler
Creates adouble
sample.- Returns:
- a sample.
-
withUniformRandomProvider
Description copied from interface:SharedStateSampler
Create 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
-