Class BetaDistribution.ChengBetaSampler
java.lang.Object
org.apache.commons.math3.distribution.BetaDistribution.ChengBetaSampler
- Enclosing class:
BetaDistribution
Utility class implementing Cheng's algorithms for beta distribution sampling.
R. C. H. Cheng, "Generating beta variates with nonintegral shape parameters.". Communications of the ACM, 21, 317–322, 1978.
- Since:
- 3.6
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static doublealgorithmBB(RandomGenerator random, double a0, double a, double b) Returns one sample using Cheng's BB algorithm, when both α and β are greater than 1.private static doublealgorithmBC(RandomGenerator random, double a0, double a, double b) Returns one sample using Cheng's BC algorithm, when at least one of α and β is smaller than 1.(package private) static doublesample(RandomGenerator random, double alpha, double beta) Returns one sample using Cheng's sampling algorithm.
-
Constructor Details
-
ChengBetaSampler
private ChengBetaSampler()
-
-
Method Details
-
sample
Returns one sample using Cheng's sampling algorithm.- Parameters:
random- random generator to usealpha- distribution first shape parameterbeta- distribution second shape parameter- Returns:
- sampled value
-
algorithmBB
Returns one sample using Cheng's BB algorithm, when both α and β are greater than 1.- Parameters:
random- random generator to usea0- distribution first shape parameter (α)a- min(α, β) where α, β are the two distribution shape parametersb- max(α, β) where α, β are the two distribution shape parameters- Returns:
- sampled value
-
algorithmBC
Returns one sample using Cheng's BC algorithm, when at least one of α and β is smaller than 1.- Parameters:
random- random generator to usea0- distribution first shape parameter (α)a- max(α, β) where α, β are the two distribution shape parametersb- min(α, β) where α, β are the two distribution shape parameters- Returns:
- sampled value
-