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 when0 < 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
Fields Modifier and Type Field Description private double
bGSOptim
Optimization (see code).private double
oneOverAlpha
Inverse of "alpha".-
Fields inherited from class org.apache.commons.rng.sampling.distribution.AhrensDieterMarsagliaTsangGammaSampler.BaseGammaSampler
alpha, rng, theta
-
-
Constructor Summary
Constructors Constructor Description AhrensDieterGammaSampler(UniformRandomProvider rng, double alpha, double theta)
AhrensDieterGammaSampler(UniformRandomProvider rng, AhrensDieterMarsagliaTsangGammaSampler.AhrensDieterGammaSampler source)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description double
sample()
Creates adouble
sample.SharedStateContinuousSampler
withUniformRandomProvider(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.-
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
-
-
-
-
Constructor Detail
-
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:
java.lang.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 Detail
-
sample
public double sample()
Description copied from interface:ContinuousSampler
Creates adouble
sample.- Returns:
- a sample.
-
withUniformRandomProvider
public SharedStateContinuousSampler withUniformRandomProvider(UniformRandomProvider rng)
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
-
-