Class BetaDistribution.ChengBetaSampler
- java.lang.Object
-
- org.apache.commons.math3.distribution.BetaDistribution.ChengBetaSampler
-
- Enclosing class:
- BetaDistribution
private static final class BetaDistribution.ChengBetaSampler extends java.lang.Object
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 Modifier Constructor Description private
ChengBetaSampler()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description private static double
algorithmBB(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 double
algorithmBC(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 double
sample(RandomGenerator random, double alpha, double beta)
Returns one sample using Cheng's sampling algorithm.
-
-
-
Method Detail
-
sample
static double sample(RandomGenerator random, double alpha, double beta)
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
private static double algorithmBB(RandomGenerator random, double a0, double a, double b)
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
private static double algorithmBC(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.- 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
-
-