Class AhrensDieterMarsagliaTsangGammaSampler.MarsagliaTsangGammaSampler
java.lang.Object
org.apache.commons.rng.sampling.distribution.AhrensDieterMarsagliaTsangGammaSampler.BaseGammaSampler
org.apache.commons.rng.sampling.distribution.AhrensDieterMarsagliaTsangGammaSampler.MarsagliaTsangGammaSampler
- All Implemented Interfaces:
ContinuousSampler, SharedStateContinuousSampler, SharedStateSampler<SharedStateContinuousSampler>
- Enclosing class:
AhrensDieterMarsagliaTsangGammaSampler
private static final class AhrensDieterMarsagliaTsangGammaSampler.MarsagliaTsangGammaSampler
extends AhrensDieterMarsagliaTsangGammaSampler.BaseGammaSampler
Class to sample from the Gamma distribution when the
alpha >= 1.
Marsaglia and Tsang, A Simple Method for Generating Gamma Variables. ACM Transactions on Mathematical Software, Volume 26 Issue 3, September, 2000.
- Since:
- 1.0
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final doubleOptimization (see code).private final doubleOptimization (see code).private final NormalizedGaussianSamplerGaussian sampling.private static final double1/3.Fields inherited from class AhrensDieterMarsagliaTsangGammaSampler.BaseGammaSampler
alpha, rng, theta -
Constructor Summary
ConstructorsConstructorDescriptionMarsagliaTsangGammaSampler(UniformRandomProvider rng, double alpha, double theta) MarsagliaTsangGammaSampler(UniformRandomProvider rng, AhrensDieterMarsagliaTsangGammaSampler.MarsagliaTsangGammaSampler 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 AhrensDieterMarsagliaTsangGammaSampler.BaseGammaSampler
toStringMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface ContinuousSampler
samples, samples
-
Field Details
-
ONE_THIRD
private static final double ONE_THIRD1/3.- See Also:
-
dOptim
private final double dOptimOptimization (see code). -
cOptim
private final double cOptimOptimization (see code). -
gaussian
Gaussian sampling.
-
-
Constructor Details
-
MarsagliaTsangGammaSampler
MarsagliaTsangGammaSampler(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
-
MarsagliaTsangGammaSampler
MarsagliaTsangGammaSampler(UniformRandomProvider rng, AhrensDieterMarsagliaTsangGammaSampler.MarsagliaTsangGammaSampler 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
-