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 thealpha >= 1.Marsaglia and Tsang, A Simple Method for Generating Gamma Variables. ACM Transactions on Mathematical Software, Volume 26 Issue 3, September, 2000.
-
-
Field Summary
Fields Modifier and Type Field Description private doublecOptimOptimization (see code).private doubledOptimOptimization (see code).private NormalizedGaussianSamplergaussianGaussian sampling.private static doubleONE_THIRD1/3.-
Fields inherited from class org.apache.commons.rng.sampling.distribution.AhrensDieterMarsagliaTsangGammaSampler.BaseGammaSampler
alpha, rng, theta
-
-
Constructor Summary
Constructors Constructor Description MarsagliaTsangGammaSampler(UniformRandomProvider rng, double alpha, double theta)MarsagliaTsangGammaSampler(UniformRandomProvider rng, AhrensDieterMarsagliaTsangGammaSampler.MarsagliaTsangGammaSampler source)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description doublesample()Creates adoublesample.SharedStateContinuousSamplerwithUniformRandomProvider(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
-
-
-
-
Field Detail
-
ONE_THIRD
private static final double ONE_THIRD
1/3.- See Also:
- Constant Field Values
-
dOptim
private final double dOptim
Optimization (see code).
-
cOptim
private final double cOptim
Optimization (see code).
-
gaussian
private final NormalizedGaussianSampler gaussian
Gaussian sampling.
-
-
Constructor Detail
-
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:
java.lang.IllegalArgumentException- ifalpha <= 0ortheta <= 0
-
MarsagliaTsangGammaSampler
MarsagliaTsangGammaSampler(UniformRandomProvider rng, AhrensDieterMarsagliaTsangGammaSampler.MarsagliaTsangGammaSampler source)
- Parameters:
rng- Generator of uniformly distributed random numbers.source- Source to copy.
-
-
Method Detail
-
sample
public double sample()
Description copied from interface:ContinuousSamplerCreates adoublesample.- Returns:
- a sample.
-
withUniformRandomProvider
public SharedStateContinuousSampler withUniformRandomProvider(UniformRandomProvider rng)
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
-
-