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 java.lang.Object implements SharedStateContinuousSampler
Base class to implement Cheng's algorithms for the beta distribution.
-
-
Field Summary
Fields Modifier and Type Field Description protected double
a
First shape parameter.protected boolean
aIsAlphaShape
Flag set to true ifa
is the beta distribution alpha shape parameter.protected double
alpha
The algorithm alpha factor.protected double
b
Second shape parameter.protected double
logAlpha
The logarithm of the alpha factor.protected UniformRandomProvider
rng
Underlying source of randomness.
-
Constructor Summary
Constructors Constructor Description BaseChengBetaSampler(UniformRandomProvider rng, boolean aIsAlphaShape, double a, double b)
BaseChengBetaSampler(UniformRandomProvider rng, ChengBetaSampler.BaseChengBetaSampler source)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected double
computeX(double w)
Compute the sample result X.java.lang.String
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
sample, samples, samples
-
Methods inherited from interface org.apache.commons.rng.sampling.SharedStateSampler
withUniformRandomProvider
-
-
-
-
Field Detail
-
aIsAlphaShape
protected final boolean aIsAlphaShape
Flag set to true ifa
is the beta distribution alpha shape parameter. Otherwisea
is the beta distribution beta shape parameter.From the original Cheng paper this is equal to the result of:
a == a0
.
-
a
protected final double a
First shape parameter. The meaning of this is dependent on theaIsAlphaShape
flag.
-
b
protected final double b
Second shape parameter. The meaning of this is dependent on theaIsAlphaShape
flag.
-
rng
protected final UniformRandomProvider rng
Underlying source of randomness.
-
alpha
protected final double alpha
The 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 logAlpha
The logarithm of the alpha factor.
-
-
Constructor Detail
-
BaseChengBetaSampler
BaseChengBetaSampler(UniformRandomProvider rng, boolean aIsAlphaShape, double a, double b)
- Parameters:
rng
- Generator of uniformly distributed random numbers.aIsAlphaShape
- true ifa
is 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 Detail
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
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
-
-