Class ChengBetaSampler.BaseChengBetaSampler
java.lang.Object
org.apache.commons.rng.sampling.distribution.ChengBetaSampler.BaseChengBetaSampler
- All Implemented Interfaces:
ContinuousSampler, SharedStateContinuousSampler, SharedStateSampler<SharedStateContinuousSampler>
- Direct Known Subclasses:
ChengBetaSampler.ChengBBBetaSampler, ChengBetaSampler.ChengBCBetaSampler
- Enclosing class:
ChengBetaSampler
private abstract static class ChengBetaSampler.BaseChengBetaSampler
extends Object
implements SharedStateContinuousSampler
Base class to implement Cheng's algorithms for the beta distribution.
- Since:
- 1.0
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final doubleFirst shape parameter.protected final booleanFlag set to true ifais the beta distribution alpha shape parameter.protected final doubleThe algorithm alpha factor.protected final doubleSecond shape parameter.protected final doubleThe logarithm of the alpha factor.protected final UniformRandomProviderUnderlying source of randomness. -
Constructor Summary
ConstructorsConstructorDescriptionBaseChengBetaSampler(UniformRandomProvider rng, boolean aIsAlphaShape, double a, double b) -
Method Summary
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface ContinuousSampler
sample, samples, samplesMethods inherited from interface SharedStateSampler
withUniformRandomProvider
-
Field Details
-
aIsAlphaShape
protected final boolean aIsAlphaShapeFlag set to true ifais the beta distribution alpha shape parameter. Otherwiseais the beta distribution beta shape parameter.From the original Cheng paper this is equal to the result of:
a == a0. -
a
protected final double aFirst shape parameter. The meaning of this is dependent on theaIsAlphaShapeflag. -
b
protected final double bSecond shape parameter. The meaning of this is dependent on theaIsAlphaShapeflag. -
rng
Underlying source of randomness. -
alpha
protected final double alphaThe algorithm alpha factor. This is not the beta distribution alpha shape parameter. It is the sum of the two shape parameters (a + b. -
logAlpha
protected final double logAlphaThe logarithm of the alpha factor.
-
-
Constructor Details
-
BaseChengBetaSampler
BaseChengBetaSampler(UniformRandomProvider rng, boolean aIsAlphaShape, double a, double b) - Parameters:
rng- Generator of uniformly distributed random numbers.aIsAlphaShape- true ifais the beta distribution alpha shape parameter.a- Distribution first shape parameter.b- Distribution second shape parameter.
-
BaseChengBetaSampler
BaseChengBetaSampler(UniformRandomProvider rng, ChengBetaSampler.BaseChengBetaSampler source) - Parameters:
rng- Generator of uniformly distributed random numbers.source- Source to copy.
-
-
Method Details
-
toString
-
computeX
protected double computeX(double w) Compute the sample result X.If a == a0 deliver X = W/(b + W); otherwise deliver X = b/(b + W).
The finalisation step is shared between the BB and BC algorithm (as step 5 of the BB algorithm and step 6 of the BC algorithm).
- Parameters:
w- Algorithm value W.- Returns:
- the sample value
-